public static void InitData(DataContext context) { User user = new User { Email = "*****@*****.**", Login = "******", Name = "test", Password = "******", UserId = 1 }; Service service = new Service { ServiceId = 1, Address = "test", Category = Domain.Models.Enum.Category.IT, Description = "testtest", Name = "Repair", UserId = 1 }; PathPhoto photo1 = new PathPhoto { Path = "https://sun1-84.userapi.com/c855224/v855224051/182eeb/TwTJNm6TOzo.jpg", ServiceId = 1, PhotoId = 1 }; }
public async Task <JsonResult> AddPhoto([FromBody] PathPhoto photo) { var result = await _photoEditor.AddPhoto(photo.PhotoId, photo.Path); return(new JsonResult("") { StatusCode = 200, Value = JsonConvert.SerializeObject(new { PathPhotoId = result }) }); }
public async Task <int> AddPhoto(int serviceId, string path) { var photo = new PathPhoto { Path = path, ServiceId = serviceId }; await _dataContext.AddAsync(photo); await _dataContext.SaveChangesAsync(); return(photo.PhotoId); }