Ejemplo n.º 1
0
        // [ValidateAntiForgeryToken]
        public async Task <IActionResult> Create(SystemFormViewModel model)
        {
            try
            {
                model.SystemUserId = UserId;
                if (ModelState.IsValid)
                {
                    var item = _mapper.Map <SystemFormViewModel, SystemForm>(model);
                    await _systemFormRepository.InsertAsync(item);

                    ErrorMessage = Resources.Messages.ChangesSavedSuccessfully;
                    if (Request.Form.Keys.Contains("SaveAndReturn"))
                    {
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        return(RedirectToAction("Edit", new { id = item.Id }));
                    }
                }
                return(View(model));
            }
            catch (Exception e)
            {
                Log.Error(e, e.Message);
                return(View("~/Views/Shared/Error.cshtml", new ErrorViewModel {
                    RequestId = e.Message
                }));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id)
        {
            try
            {
                SystemForm item = await _systemFormRepository.GetByIDAsync(id);

                SystemFormViewModel model = _mapper.Map <SystemForm, SystemFormViewModel>(item);
                return(View(model));
            }
            catch (Exception e)
            {
                Log.Error(e, e.Message);
                return(View("~/Views/Shared/Error.cshtml", new ErrorViewModel {
                    RequestId = e.Message
                }));
            }
        }