public PurchaseRequest UpdatePrState(PurchaseRequest pr, ProcessStateEnum e, string detail, string userName) { pr.Status = e; if (e == ProcessStateEnum.SubmittedByRequestor) { if ((0 >= pr.TotalPrice) && (pr.TotalPrice <= 100000)) { pr.ProcessCategory = ProcessDetailCategory.PrValueUnder1k; var pcs = Data.Models.ChecklistModel.FindAllByProcessCategory(pr.ProcessCategory); foreach (var pc in pcs) { //Data.Models } //pr.Checklist.Add(pc); } if ((100000 > pr.TotalPrice) && (pr.TotalPrice <= 2000000)) { pr.ProcessCategory = ProcessDetailCategory.PrValueUnder20k; var pcs = Data.Models.ChecklistModel.FindAllByProcessCategory(pr.ProcessCategory); foreach (var pc in pcs) { //Data.Models } //pr.Checklist.Add(pc); } if ((2000000 > pr.TotalPrice) && (pr.TotalPrice <= 5000000)) { pr.ProcessCategory = ProcessDetailCategory.PrValueBetweek20kTo50k; } if (pr.TotalPrice > 5000000) { pr.ProcessCategory = ProcessDetailCategory.PrValueMoreThan50k; } } Data.Models.PurchaseRequestModel.AddOrUpdate(pr, userName); Employee employee = Data.Models.EmployeeModel.FindByUserId(userName); Workflow wf = new Workflow { DateTime = DateTime.Now, ProcessTypeEnum = ProcessTypeEnum.PurchaseRequest, ProcessStateEnum = pr.Status, //UserName = userName, //Employee = employee, EmployeeFullName = employee.FullName, EmployeeUserName = employee.UserId, EmployeePtjCode = employee.PtjCode, EmployeeId = employee.Id, Description = "", ProcessId = pr.Id, }; Data.Models.WorkflowModel.Add(wf, userName); return pr; }