public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } List <StatusForList> types = new List <StatusForList>(); foreach (Type item in typeService.GetAll()) { types.Add(new StatusForList { Key = item.ID.ToString(), Display = item.Description }); } List <CheckboxItem> admissions = new List <CheckboxItem>(); foreach (var item in admissionService.GetAll()) { string display = item.Role + " (" + item.Description + ")"; if (checkpointService.IsMatchAdmission(id, item.ID)) { admissions.Add(new CheckboxItem() { ID = item.ID, Display = display, IsChecked = true }); } else { admissions.Add(new CheckboxItem() { ID = item.ID, Display = display, IsChecked = false }); } } CheckpointViewModel model = (CheckpointViewModel)checkpointService.Get(id); if (model != null) { model.StatusList = new SelectList(new List <StatusForList> { new StatusForList { Key = "Пропуск", Display = "Пропуск" }, new StatusForList { Key = "Отметка", Display = "Отметка" } }, "Key", "Display"); model.TypeList = new SelectList(types, "Key", "Display"); model.AdmissionList = admissions; return(View(model)); } return(HttpNotFound()); }
public void Is_Match_Admission() { //Arrange int checkpointID = id, admissionID = id; unitWorkMoq.Setup(x => x.CheckpointAdmission.FindFirst(It.IsAny <Func <CheckpointAdmission, bool> >())) .Returns(itemsCheckpointAdmission.Where(i => i.CheckpointID == checkpointID && i.AdmissionID == admissionID).FirstOrDefault()); //Act var result = serviceMock.IsMatchAdmission(checkpointID, admissionID); //Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(bool)); Assert.IsTrue(result); }