Exemplo n.º 1
0
        public ActionResult ViewCase(int flowCaseId)
        {
            ApplicationUser manager    = new ApplicationUser(WFEntities, this.Username);
            PropertiesValue properties = manager.GetProperties(flowCaseId);
            FlowInfo        info       = manager.GetFlowAndCase(flowCaseId);

            manager.SetCaseAsViewed(flowCaseId, this.Username);
            manager.UpdateLastChecked(flowCaseId, this.Username);
            WF_FlowTypes flowType = manager.GetFlowTypeById(info.FlowTypeId);

            if (flowType.TemplateType.HasValue && flowType.TemplateType.Value == 7)
            {
                WF_FlowPropertys prop = properties.PropertyInfo.FirstOrDefault(p => p.PropertyName.ToLower().Equals("brand") && p.StatusId < 0);
                if (prop != null)
                {
                    string brand = properties.Values.FirstOrDefault(p => p.PropertyId == prop.FlowPropertyId)?.StringValue;
                    Dictionary <string, string> 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;
                }
            }
            ViewBag.Properties  = properties;
            ViewBag.Attachments = manager.GetAttachments(flowCaseId);
            ViewBag.FlowType    = flowType;
            ViewBag.History     = manager.GetCaseHistory(info.CaseInfo.FlowCaseId, info.CaseInfo.BaseFlowCaseId);
            return(PartialView(info));
        }
        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)));
        }