SaeedP
Well-known member
- Joined
- Oct 21, 2020
- Messages
- 116
- Programming Experience
- 3-5
Hello,
This is the part of a controller which uploads files in ASP.net Core. My question is why do we return a value for this case?
thanks
This is the part of a controller which uploads files in ASP.net Core. My question is why do we return a value for this case?
C#:
Image file = await _context.Images.FirstOrDefaultAsync(f => f.FileName == imageData.File.FileName);
if (file == null)
{
Image image = new Image()
{
ContentType = imageData.File.ContentType,
DateModified = DateTime.Now,
FileName = imageData.File.FileName,
Path = path,
Description = imageData.Description
};
_context.Images.Add(image);
await _context.SaveChangesAsync();
return CreatedAtAction(nameof(GetImage), new { id = image.ImageId }, image);
thanks