public IHttpActionResult Put(int id, [FromBody] Admission item) { if (item != null) { if (id == item.ID) { service.Edit(item); return(Ok(item)); } } return(BadRequest()); }
public void Edit() { //Arrange int updatedAdmission = 0; unitWorkMoq.Setup(x => x.Admission.Update(It.IsAny <Admission>())).Callback(() => { updatedAdmission++; }); //Act serviceMock.Edit(itemsAdmission[0]); //Assert Assert.AreNotEqual(0, updatedAdmission); Assert.AreEqual(1, updatedAdmission); }
public ActionResult Edit(AdmissionViewModel model) { if (string.IsNullOrEmpty(model.Description)) { ModelState.AddModelError("Description", "Описание должно быть заполнено"); } if (string.IsNullOrEmpty(model.Role)) { ModelState.AddModelError("Role", "Выберите роль"); } if (ModelState.IsValid) { service.Edit(new Admission { ID = model.ID, Description = model.Description, Role = model.Role }); return(RedirectToAction("Index", "Admission")); } else { model.RoleList = new SelectList(new List <StatusForList> { new StatusForList { Key = "Сотрудник", Display = "Сотрудник" }, new StatusForList { Key = "Студент", Display = "Студент" } }, "Key", "Display"); return(View(model)); } }