示例#1
0
        public ActionResult CreateDocumentNumbering(DocumentNumberingViewModel model)
        {
            var fiscalyear = CurrentFiscalYear;

            model.FiscalYearId = fiscalyear != null ? fiscalyear.FiscalYearId : 0;
            if (model.Validate())
            {
                try
                {
                    db.DocumentNumberingRepo.Update(AutomapperConfig.Mapper.Map <DocumentNumbering>(model));
                }
                catch (Exception ex)
                {
                    model.ErrorMessages.Add(ex.GetExceptionMessages());
                }
            }
            if (model.HasError)
            {
                Response.StatusCode = (int)HttpStatusCode.SeeOther;
                return(Json(new { redirecturl = "/error/badrequest" }));
                //return Json(new { success = false, errors = model.ErrorMessages });
            }

            Response.StatusCode = (int)HttpStatusCode.OK;
            //return Json(new { success = true });
            return(RedirectToAction("DocumentNumberingList"));
        }
示例#2
0
        public PartialViewResult CreateDocumentNumbering(int id = 0)
        {
            var model = new DocumentNumberingViewModel();

            if (id > 0)
            {
                model = AutomapperConfig.Mapper.Map <DocumentNumberingViewModel>(db.DocumentNumberingRepo.GetById(id));
            }
            if (model == null)
            {
                Response.StatusCode = (int)HttpStatusCode.OK;
                return(PartialView(BadRequestView));
            }
            return(PartialView(model));
        }