Resolved why do we return a value for uploading an image in this controller?

SaeedP

Well-known member
Joined
Oct 21, 2020
Messages
99
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?

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

 
Solution
It appears to be invoking an action that gets an Image record, so it's basically showing you the record you just created. That's common for any type of record, simultaneously confirming the creation and allowing you to make changes if required.
It appears to be invoking an action that gets an Image record, so it's basically showing you the record you just created. That's common for any type of record, simultaneously confirming the creation and allowing you to make changes if required.
 
Solution
Back
Top Bottom