Ejemplo n.º 1
0
        public JsonResult New(SubProcessModel model)
        {
            try
            {
                SubProcess subProcess = new SubProcess();
                model.Process = this.processService.GetDataById(model.ProcessId);
                if (ModelState.IsValid)
                {
                    bool ifExists = this.subProcessService.CheckDataAndCodeIfExist(model);
                    if (!ifExists)
                    {
                        subProcess.Process = model.Process;
                        subProcess.Code = model.Code.ToUpper();
                        subProcess.Name = model.Name;
                        subProcess.Description = model.Description;
                        subProcess.Active = true;
                        subProcess.DateCreated = DateTime.Now;
                        subProcess.CreatedBy = User.Identity.Name.ToString();
                        subProcess.Id = this.subProcessService.Create(subProcess);
                        model.Id = subProcess.Id;
                        return Json(new { result = Base.Encrypt(subProcess.Id.ToString()), message = MessageCode.saved, code = StatusCode.saved, content= subProcess.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 });
            }
        }
Ejemplo n.º 2
0
        public JsonResult Manage(SubProcessModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {

                    bool ifExists = this.subProcessService.CheckDataIfExists(model);
                    if (!ifExists)
                    {
                        SubProcess subProcess = new SubProcess();
                        Process process = new Process();
                        process = this.processService.GetDataById(model.ProcessId);
                        subProcess = this.subProcessService.GetDataById(model.Id);
                        subProcess.Id = model.Id;
                        subProcess.Process = process;
                        subProcess.Code = model.Code;
                        subProcess.Name = model.Name;
                        subProcess.Description = model.Description;
                        subProcess.Active = model.Active;
                        subProcess.DateModified = DateTime.Now;
                        subProcess.ModifiedBy = User.Identity.Name.ToString();
                        this.subProcessService.SaveChanges(subProcess);
                        return Json(new { result = Base.Encrypt(subProcess.Id.ToString()), message = MessageCode.modified, code = StatusCode.modified, content = subProcess.Name });
                    }
                    return Json(new { result = StatusCode.existed, message = MessageCode.existed, code = StatusCode.existed, content = model.Name });
                }
                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 });
            }
        }
Ejemplo n.º 3
0
 public ActionResult New()
 {
     SubProcessModel entity = new SubProcessModel();
     entity.ProcessList = this.service.GetProcessList(0);
     return View(entity);
 }
Ejemplo n.º 4
0
        public ActionResult Manage(int id)
        {
            try
            {
                SubProcessModel model = new SubProcessModel();
                SubProcess subProcess = this.subProcessService.GetDataById(id);
                model.Id = subProcess.Id;
                model.Active = subProcess.Active;
                model.Code = subProcess.Code;
                model.Name = subProcess.Name;
                model.Active = subProcess.Active;
                model.Description = subProcess.Description;
                model.ProcessId = subProcess.Process.Id;
                model.CreatedBy = subProcess.CreatedBy;
                model.DateCreated = subProcess.DateCreated;
                model.ProcessList = this.service.GetProcessList(subProcess.Process.Id);
                if (model != null)
                    return View(model);
            }
            catch (Exception)
            {

            }
            return RedirectToAction("Index");
        }