public JsonResult New(ProcessModel model) { try { if (ModelState.IsValid) { Process process = new Process(); bool ifExists = this.processService.CheckDataAndCodeIfExist(model); if (!ifExists) { process.SystemCode = model.SystemCode; process.Code = Base.GenerateCode(model.SystemCode, model.Code).ToUpper(); process.Name = model.Name; process.Description = model.Description; process.Active = true; process.DateCreated = DateTime.Now; process.CreatedBy = User.Identity.Name.ToString(); process.Id = this.processService.Create(process); model.Id = process.Id; return Json(new { result = Base.Encrypt(process.Id.ToString()), message = MessageCode.saved, code = StatusCode.saved, content= model.Name }); } return Json(new { result = StatusCode.existed, message = MessageCode.existed, code = StatusCode.existed }); } return Json(new { result = StatusCode.failed, message = MessageCode.error, code = StatusCode.invalid }); } catch (Exception ex) { return Json(new { result = StatusCode.failed, message = ex.Message.ToString(), code = StatusCode.failed, content = model.Name.ToString() }); } }
public JsonResult Manage(ProcessModel model) { try { if (ModelState.IsValid) { bool ifExists = this.processService.CheckDataIfExists(model); if (!ifExists) { Process process = new Process(); process = this.processService.GetDataById(model.Id); process.SystemCode = model.SystemCode.ToUpper(); process.Code = Base.GenerateCode(model.SystemCode, model.Code).ToUpper(); process.Name = model.Name; process.Description = model.Description; process.Active = model.Active; process.DateModified = DateTime.Now; process.ModifiedBy = User.Identity.Name.ToString(); this.processService.SaveChanges(process); return Json(new { result = Base.Encrypt(process.Id.ToString()), message = MessageCode.modified, code = StatusCode.modified, content = process.Name }); } return Json(new { result = StatusCode.existed, message = MessageCode.existed, code = StatusCode.existed }); } return Json(new { result = StatusCode.failed, message = MessageCode.error, code = StatusCode.invalid }); } catch (Exception ex) { return Json(new { result = StatusCode.failed, message = ex.Message.ToString(), code = StatusCode.failed, content = model.Name }); } }
public ActionResult New() { ProcessModel model = new ProcessModel(); model.SystemList = this.service.GetAllSystems(string.Empty); return View(model); }
public ActionResult Manage(int id) { try { Process process = this.processService.GetDataById(id); ProcessModel model = new ProcessModel(); model.SystemList = this.service.GetAllSystems(process.SystemCode); model.SystemCode = process.SystemCode; model.Code = process.Code; model.Name = process.Name; model.Description = process.Description; model.DateCreated = process.DateCreated; model.CreatedBy = process.CreatedBy; model.Id = process.Id; model.Active = process.Active; if (model != null) return View(model); } catch (Exception) { } return RedirectToAction("Index"); }