Changeset 13f1472 for resTools_backend/backend/Services/MenuService.cs
- Timestamp:
- 09/18/22 18:09:53 (2 years ago)
- Branches:
- master
- Parents:
- 49b0bbd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
resTools_backend/backend/Services/MenuService.cs
r49b0bbd r13f1472 10 10 public Task AddMenu(CreateMenuItemRequest menu); 11 11 public Task RemoveMenu(int id); 12 public Task UploadImage(int id, IFormFile file); 12 13 } 13 14 public class MenuService : IMenuService … … 29 30 Title = menu.Title, 30 31 Description = menu.Description, 31 Price = menu.Price 32 }); 32 Price = menu.Price, 33 Alergens = menu.Alergens, 34 IsVipOnly = menu.IsVipOnly, 35 Image = Array.Empty<byte>() 36 }) ; 33 37 _context.Restoraunts.Update(res); 34 38 await _context.SaveChangesAsync(); … … 42 46 await _context.SaveChangesAsync(); 43 47 } 48 49 public async Task UploadImage(int id, IFormFile file) 50 { 51 using (var memoryStream = new MemoryStream()) 52 { 53 await file.CopyToAsync(memoryStream); 54 var menuItem = await _context.MenuItems.FindAsync(id); 55 menuItem.Image = memoryStream.ToArray(); 56 _context.MenuItems.Update(menuItem); 57 _context.SaveChanges(); 58 } 59 } 44 60 } 45 61 }
Note:
See TracChangeset
for help on using the changeset viewer.