public ActionResult EditCase(int id) { ApplicationUser manager = new ApplicationUser(WFEntities, this.Username); FlowInfo flowInfo = manager.GetFlowAndCase(id); var properties = manager.GetProperties(id); ViewBag.Properties = properties; var attachments = manager.GetAttachments(id); ViewBag.Attachments = attachments; ViewBag.FinalNotifyUsers = manager.GetFinalNotifyUsers(id); var flowType = WFEntities.WF_FlowTypes.FirstOrDefault(p => p.FlowTypeId == flowInfo.FlowTypeId); ViewBag.FlowType = flowType; ViewBag.HasCoverDuties = WFEntities.WF_FlowGroups.FirstOrDefault(p => p.FlowTypeId == flowInfo.FlowTypeId && p.StatusId > 0)?.HasCoverUsers; ViewBag.LeaveTypes = WFUtilities.GetLeaveType(RouteData.Values["lang"] as string); if (flowType.TemplateType.HasValue) { if (flowType.TemplateType.Value == 1) { ViewBag.Cities = WFEntities.Cities.Where(p => p.CountryCode == Country).AsNoTracking().ToArray(); } else if (flowType.TemplateType.Value == 7) { var prop = properties.PropertyInfo.FirstOrDefault(p => p.PropertyName.ToLower().Equals("brand") && p.StatusId < 0); if (prop != null) { var brand = properties.Values.FirstOrDefault(p => p.PropertyId == prop.FlowPropertyId)?.StringValue; var shopList = WFEntities.BLSShopView .Where(s => s.Brand.ToLower().Equals(brand.ToLower())) .Select(s => new { s.ShopCode, s.ShopName }) .ToDictionary(s => s.ShopCode, s => s.ShopName); ViewBag.ShopList = shopList; } } else if (flowType.TemplateType.Value == 2) { UserStaffInfo userInfo = WFUtilities.GetUserStaffInfo(this.Username); double balance = userInfo?.LeaveBalance ?? 0; double notstarted = manager.GetNotStartedBalance(Username); double unapproved = manager.GetUnApprovedBalance(Username); ViewBag.DisplayBalance = notstarted + balance; ViewBag.ValidBalance = balance > unapproved ? balance - unapproved : 0; } } return(PartialView(flowInfo)); }
public ActionResult FillFormValue(int flowtypeid) { ViewBag.Country = Country; UserStaffInfo userInfo = WFUtilities.GetUserStaffInfo(this.Username); ViewBag.CurrentDep = userInfo?.DepartmentName; WF_FlowTypes flowType = WFEntities.WF_FlowTypes.FirstOrDefault(p => p.FlowTypeId == flowtypeid && p.StatusId > 0); ViewBag.FlowType = flowType; if (flowType?.TemplateType.HasValue == true) { if (flowType.TemplateType.Value == (int)FlowTemplateType.DynamicTemplate) { var props = WFEntities.WF_FlowGroups.AsNoTracking() .Include("WF_FlowPropertys") .FirstOrDefault(p => p.FlowTypeId == flowtypeid && p.StatusId > 0)?.WF_FlowPropertys.ToArray(); return(PartialView("FillDynamicFormValue", props)); } if (flowType.TemplateType.Value == (int)FlowTemplateType.StoreApprovalTemplate) { ViewBag.Cities = WFEntities.Cities.Where(p => p.CountryCode == Country).AsNoTracking().ToArray(); } else if (flowType.TemplateType.Value == (int)FlowTemplateType.LeaveTemplate) { ApplicationUser manager = new ApplicationUser(WFEntities, this.Username); double balance = userInfo?.LeaveBalance ?? 0; double notstarted = manager.GetNotStartedBalance(Username); double unapproved = manager.GetUnApprovedBalance(Username); ViewBag.NotStartedBalance = notstarted; ViewBag.APIReturnBalance = balance; ViewBag.DisplayBalance = notstarted + balance; ViewBag.ValidBalance = balance > unapproved ? balance - unapproved : 0; ViewBag.LeaveTypes = WFUtilities.GetLeaveType(RouteData.Values["lang"] as string); } } ViewBag.StaffNo = this.Username; ViewBag.HasCoverDuties = WFEntities.WF_FlowGroups.FirstOrDefault(p => p.FlowTypeId == flowtypeid && p.StatusId > 0)?.HasCoverUsers; return(PartialView("FillFormValue", WFEntities.WF_FlowGroups.AsNoTracking().Include("WF_FlowPropertys").FirstOrDefault(p => p.FlowTypeId == flowtypeid && p.StatusId > 0))); }