public static bool UpdateCarPhoto(CarDbContext context, UpdateCarPhoto newCarPhoto) { var carModel = context.CarModels.SingleOrDefault(cb => cb.Id == newCarPhoto.CarModelId); if (carModel == null) { return(false); } var carPhoto = context.CarPhotos.SingleOrDefault(cb => cb.Id == newCarPhoto.Id); if (carPhoto == null) { return(false); } carPhoto.Photo = newCarPhoto.Photo; carPhoto.CarModel = carModel; carPhoto.CarModelId = carModel.Id; context.SaveChanges(); return(true); }
public JsonResult Put([FromBody] UpdateCarPhoto newCarPhoto) { CarDbCommand.UpdateCarPhoto(_context, newCarPhoto); return(new JsonResult(null)); }