public ActionResult Add(UniMedCrudViewModel model) { //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - AddUniMed Controller Begin")); try { // Add add logic here if (ModelState.IsValid) { var committed = _serviceUniMed.Insert(model.UniMed, null); _unitOfWork.SaveChanges(); if (committed) { //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - AddUniMed Controller End")); return(RedirectToAction("Add")); } } } catch (Exception ex) { //LoggerFactory.CreateLog().Error(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - AddUniMed Controller ERROR"), ex); } ModelState.AddModelError("", PresentationResources.Error); return(View("UniMedAddView", new UniMedCrudViewModel(_serviceUniMed, _serviceAlim))); }
// GET public ActionResult Add() { //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - AddUniMed Controller Begin")); try { // Add add logic here var model = new UniMedCrudViewModel(_serviceUniMed, _serviceAlim); //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - AddUniMed Controller End")); return(View("UniMedAddView", model)); } catch (Exception ex) { //LoggerFactory.CreateLog().Error(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - AddUniMed Controller ERROR"), ex); } return(RedirectToAction("Index", "Home")); }
// GET public ActionResult Remove(int id) { //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - RemoveUniMed Controller Begin")); try { // Add remove logic here var model = new UniMedCrudViewModel(_serviceUniMed, _serviceAlim) { UniMed = _serviceUniMed.Find(id) }; //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - RemoveUniMed Controller End")); return(View("UniMedRemoveView", model)); } catch (Exception ex) { //LoggerFactory.CreateLog().Error(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - RemoveUniMed Controller ERROR"), ex); } return(RedirectToAction("Find")); }