コード例 #1
0
        public async Task <ActionResult> CreateProcedure(ProcedureViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.Error = CreateError();
                return(View("Error"));
            }
            try
            {
                var procedureDto = Mapper.Map <ProcedureViewModel, ProcedureDTO>(model);
                _procedureService.AddItem(procedureDto);
                _procedureService.Commit();

                TempData["Success"] = Resources.Messages.ProcedureCreatedSuccess;
                await SenEmailAboutAddProcedure(model);

                _currentUser = GetCurrentUser();
                Logger.Log.Info($"{_currentUser.Email} Added Procedure for Product #{procedureDto.ProductId} {procedureDto.ProcedureType}");
                return(RedirectToAction("ProductProcedures", new { id = model.ProductId }));
            }
            catch (Exception ex)
            {
                @ViewBag.Error = ex.ToString();
                return(View("Error"));
            }
        }