public IActionResult Put(int id, Gear gear) { // Id 1 is the unmodifiable 'dummy' gear to keep old reservations in the database if (id != gear.Id || id == 1) { return(BadRequest()); } var currentUser = GetCurrentUserProfile(); if (currentUser.Id != gear.UserProfileId) { return(Unauthorized()); } _gearRepository.Update(gear); foreach (Accessory accessory in gear.Accessories) { if (accessory.GearId != gear.Id) { return(BadRequest()); } _accessoryRepository.Update(accessory); } return(NoContent()); }
public ActionResult Edit(int id, GearType gear) { try { _gearRep.Update(id, gear); _gearRep.Save(); return(RedirectToAction("Index")); } catch { return(View()); } }