Example #1
0
        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);
        }
Example #2
0
        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());
            }
        }
Example #3
0
        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));
        }
Example #4
0
 public IActionResult Add(Manager manager)
 {
     _managerService.Add(manager);
     return(RedirectToAction("Index"));
 }