private int CreateManagerIfNotExist(OrderModel orderModel) // generic roolback { var manager = _managerService.GetByName(orderModel?.ManagerModel?.SecondName); if (manager != null) { return(manager.ManagerId); } var managerId = _managerService.Add(new ManagerModel { SecondName = orderModel?.ManagerModel?.SecondName }); return(managerId); }
public ActionResult Create([Bind(Include = "Id,LastName")] ManagerViewModel managerViewModel) { try { if (!ModelState.IsValid) { return(View(managerViewModel)); } _service.Add(Mapper.Map <ManagerDTO>(managerViewModel)); return(RedirectToAction("Index")); } catch (Exception e) { ModelState.AddModelError(string.Empty, e.Message); return(View()); } }
public ActionResult NewManager(CreateManagerViewModel manager) { if (!ModelState.IsValid) { return(View(manager)); } try { var managerId = _managerService.Add(new ManagerModel { SecondName = manager.Name, }); return(RedirectToAction("Index", "Manager")); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } return(View(manager)); }
public IActionResult Add(Manager manager) { _managerService.Add(manager); return(RedirectToAction("Index")); }