public async Task <IActionResult> PutPaymentType([FromRoute] int id, [FromBody] PaymentType paymentType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != paymentType.Id) { return(BadRequest()); } _context.Entry(paymentType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PaymentTypeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutTasky([FromRoute] Guid id, [FromBody] Tasky tasky) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tasky.Id) { return(BadRequest()); } _context.Entry(tasky).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TaskyExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutUsers(int id, Users users) { if (id != users.id) { return(BadRequest()); } _context.Entry(users).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UsersExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit([Bind(Include = "ID,Name,Age,Role,BirthDate")] Developers developers) { if (ModelState.IsValid) { db.Entry(developers).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(developers)); }
public void InsertOrUpdate(Developers developer) { if (developer.ID == default(int)) { ctx.Developers.Add(developer); } else { ctx.Entry(developer).State = System.Data.Entity.EntityState.Modified; } }
private void Update(int id, string name, int age, DateTime birthdate, Role role, List <int> skills) { using (DevContext context = new DevContext()) { var updateDeveloper = db.Developers.Where(x => x.ID == id).First(); updateDeveloper.Name = name; updateDeveloper.Age = age; updateDeveloper.BirthDate = birthdate; updateDeveloper.Role = role; updateDeveloper = UpdateSkill(skills, updateDeveloper, context); db.Entry(updateDeveloper).State = EntityState.Modified; db.SaveChanges(); } }