public async Task <IActionResult> PutCat(Guid id, Cat cat) { if (id != cat.Id) { return(BadRequest()); } _context.Entry(cat).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CatExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit(TransportBidPlanDetail transportbidplandetail) { if (ModelState.IsValid) { db.Entry(transportbidplandetail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BidPlanID = new SelectList(db.TransportBidPlans, "TransportBidPlanID", "TransportBidPlanID", transportbidplandetail.BidPlanID); ViewBag.DestinationID = new SelectList(db.AdminUnits, "AdminUnitID", "Name", transportbidplandetail.DestinationID); ViewBag.SourceID = new SelectList(db.Hubs, "HubId", "Name", transportbidplandetail.SourceID); ViewBag.ProgramID = new SelectList(db.Programs, "ProgramID", "Name", transportbidplandetail.ProgramID); return(View(transportbidplandetail)); }
public async Task <IActionResult> PutSpecies(int id, Species species) { if (id != species.Id) { return(BadRequest()); } int counter = 0; foreach (var g in _context.Species) { if (g.Name == species.Name) { counter++; break; } } if (counter != 0) { ModelState.AddModelError("Spesies", "Така порода вже існує"); } else { _context.Entry(species).State = EntityState.Modified; } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SpeciesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public virtual bool Edit(T entity) { _context.Entry(entity).State = EntityState.Modified; return(true); }