public ActionResult Delete(int id) { Device device = deviceRepository.Repository.FirstOrDefault(x => x.id == id); if (device != null) { DeleteObjectById model = new DeleteObjectById(); model.Description = "Czy napewno chcesz usunąć urządzenie: " + device.id + "?"; model.Id = id; if (Request.IsAjaxRequest()) { return PartialView("Device/_DeviceDelete", model); } return View("Delete", model); } else { InfoModel model = new InfoModel() { Description = "Podane urządzenie nie istnieje", Action = "Index", Controller = "Device" }; if (Request.IsAjaxRequest()) { return PartialView("_Info", model); } return View("Info", model); } }
public ActionResult Delete(int id) { Licence kind = licenceRepository.Repository.FirstOrDefault(x => x.id_number == id); if (kind != null) { DeleteObjectById model = new DeleteObjectById(); model.Description = "Czy napewno chcesz usunąć licencje: " + kind.name + "?"; model.Id = id; if (Request.IsAjaxRequest()) { return PartialView("Licence/_LicenceDelete", model); } return View("Delete", model); } else { InfoModel model = new InfoModel() { Description = "Podana licencja nie istnieje", Action = "Index", Controller = "Licence" }; if (Request.IsAjaxRequest()) { return PartialView("_Info", model); } return View("Info", model); } }
public ActionResult Delete(int id) { Subgroup subgroup = subgroupRepository.Repository.FirstOrDefault(x => x.id == id); if (subgroup != null) { DeleteObjectById model = new DeleteObjectById(); model.Description = "Czy napewno chcesz usunąć grupę: " + subgroup.name + "?"; model.Id = id; if (Request.IsAjaxRequest()) { return PartialView("Subgroup/_SubgroupDelete", model); } return View("Delete", model); } else { InfoModel model = new InfoModel() { Description = "Podana grupa nie istnieje", Action = "Index", Controller = "Subgroup" }; if (Request.IsAjaxRequest()) { return PartialView("_Info", model); } return View("Info", model); } }
public ActionResult Delete(int id) { Kind kind = kindRepository.Repository.FirstOrDefault(x => x.id == id); if (kind != null) { DeleteObjectById model = new DeleteObjectById(); model.Description = "Czy napewno chcesz usunąć rodzaj: " + kind.name + "?"; model.Id = id; if (Request.IsAjaxRequest()) { return PartialView("Kind/_KindDelete", model); } return View("Delete", model); } else { InfoModel model = new InfoModel() { Description = "Podany rodzaj nie istnieje", Action = "Index", Controller = "Kind" }; if (Request.IsAjaxRequest()) { return PartialView("_Info", model); } return View("Info", model); } }
public void CanDeletePerson() { Mock<IRepository<Person>> mock_person = new Mock<IRepository<Person>>(); Mock<IRepository<Section>> mock_section = new Mock<IRepository<Section>>(); mock_section.Setup(m => m.Repository).Returns(CreateSectionTab().AsQueryable()); mock_person.Setup(m => m.Repository).Returns(CreatePersonTab().AsQueryable()); PersonController controller = new PersonController(mock_person.Object, mock_section.Object); DeleteObjectById model = new DeleteObjectById() { Description = "XXXX", Id = 5 }; var redirectToRouteResult = controller.Delete(model) as RedirectToRouteResult; mock_person.Verify(m => m.DeleteObject(It.IsAny<Person>()), Times.Once()); Assert.IsNotNull(redirectToRouteResult); Assert.AreEqual("Index", redirectToRouteResult.RouteValues["Action"]); }
public ActionResult Delete(DeleteObjectById model) { try { Licence kind = new Licence() { id_number = model.Id }; licenceRepository.DeleteObject(kind); return RedirectToAction("Index"); } catch (Exception ex) { throw new Exception("Wystąpił błąd podczas usuwania licencji. Proszę skontaktować się z administratorem", ex.InnerException); } }
public void CantDeletePerson() { Mock<HttpRequestBase> request = new Mock<HttpRequestBase>(); Mock<HttpResponseBase> response = new Mock<HttpResponseBase>(); Mock<HttpContextBase> context = new Mock<HttpContextBase>(); context.Setup(c => c.Request).Returns(request.Object); context.Setup(c => c.Response).Returns(response.Object); //Add XMLHttpRequest request header request.Setup(req => req["X-Requested-With"]). Returns("XMLHttpRequest"); Mock<IRepository<Person>> mock_person = new Mock<IRepository<Person>>(); Mock<IRepository<Section>> mock_section = new Mock<IRepository<Section>>(); mock_section.Setup(m => m.Repository).Returns(CreateSectionTab().AsQueryable()); mock_person.Setup(m => m.Repository).Returns(CreatePersonTab().AsQueryable()); PersonController controller = new PersonController(mock_person.Object, mock_section.Object); controller.ControllerContext = new ControllerContext( context.Object, new RouteData(), controller); DeleteObjectById model = new DeleteObjectById() { Description = "XXXX", Id = 155 }; var viewResult = controller.Delete(model.Id) as PartialViewResult; Assert.IsNotNull(viewResult); Assert.AreEqual("_Info", viewResult.ViewName); Assert.AreEqual("Podany pracownik nie istnieje", ((InfoModel)viewResult.Model).Description); Assert.AreEqual("Index", ((InfoModel)viewResult.Model).Action); Assert.AreEqual("Person", ((InfoModel)viewResult.Model).Controller); mock_person.Verify(m => m.DeleteObject(It.IsAny<Person>()), Times.Never()); }
public ActionResult Delete(int id) { Person person = personRepository.Repository.FirstOrDefault(x => x.id == id); if (person != null) { DeleteObjectById model = new DeleteObjectById(); model.Description = "Czy napewno chcesz usunąć pracownika: " + person.id + " " + person.name + " " + person.surname + "?"; model.Id = id; if (Request.IsAjaxRequest()) { return PartialView("Person/_PersonDelete", model); } return View("Delete", model); } else { InfoModel model = new InfoModel() { Description = "Podany pracownik nie istnieje", Action = "Index", Controller = "Person" }; if (Request.IsAjaxRequest()) { return PartialView("_Info", model); } return View("Info", model); } }
public ActionResult Delete(DeleteObjectById model) { try { Person person = new Person() { id = model.Id }; personRepository.DeleteObject(person); return RedirectToAction("Index"); } catch (Exception ex) { throw new Exception("Wystąpił błąd podczas usuwania pracownika. Proszę skontaktować się z administratorem", ex.InnerException); } }
public ActionResult Delete(DeleteObjectById model) { try { Subgroup subgroup = new Subgroup() { id = model.Id }; subgroupRepository.DeleteObject(subgroup); return RedirectToAction("Index"); } catch (DbUpdateException ex) { throw new DbUpdateException("Wystąpił błąd podczas usuwania grupy. Aby usunąć rodzaj należy edytować środki trwałe tego typu.", ex.InnerException); } catch (Exception ex) { throw new Exception("Wystąpił błąd podczas usuwania grupy. Proszę skontaktować się z administratorem", ex.InnerException); } }
public ActionResult Delete(DeleteObjectById model) { Device device = new Device() { id = model.Id }; deviceRepository.DeleteObject(device); return RedirectToAction("Index"); }
public ActionResult Delete(DeleteObjectById model) { try { PeripheralDevice device = new PeripheralDevice() { id = model.Id }; peripheralDeviceRepository.DeleteObject(device); return RedirectToAction("Index"); } catch (DbUpdateException ex) { throw new DbUpdateException("Wystąpił błąd podczas usuwania urządznia peryferyjnego. Aby usunąć urządzenie peryferyjne należy edytować urządzenia tego typu.", ex.InnerException); } catch (Exception ex) { throw new Exception("Wystąpił błąd podczas usuwania urządzenia peryferyjnego. Proszę skontaktować się z administratorem", ex.InnerException); } }
public ActionResult Delete(DeleteObjectById model) { try { Kind kind = new Kind() { id = model.Id }; kindRepository.DeleteObject(kind); return RedirectToAction("Index"); } catch (DbUpdateException ex) { throw new DbUpdateException("Wystąpił błąd podczas usuwania rodzaju. Aby usunąć rodzaj należy edytować urządzenia tego typu.", ex.InnerException); } catch (Exception ex) { throw new Exception("Wystąpił błąd podczas usuwania rodzaju. Proszę skontaktować się z administratorem", ex.InnerException); } }