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));
        }
Beispiel #2
0
        public async Task <ActionResult> ChangePassword(string Password, string NewPassword, string ConfirmPassword)
        {
            if (User.Identity.Name == "Admin")
            {
                return(this.ShowErrorInModal("Admin cannot change password"));
            }
            if (NewPassword == ConfirmPassword)
            {
                LoginApiClient             login    = new LoginApiClient();
                UserStaffInfo              userInfo = WFUtilities.GetUserStaffInfo(this.Username);
                RequestResult <BoolResult> res      = await login.ChangeUserPasswordAsync(User.Identity.Name, Password, NewPassword, userInfo.Country);

                if (!string.IsNullOrEmpty(res.ReturnValue.ret_msg))
                {
                    return(this.ShowErrorInModal(res.ReturnValue.ret_msg));
                }
                return(this.ShowSuccessModal(StringResource.PASSWORD_CHANGE));
            }
            return(this.ShowErrorInModal(StringResource.PASSWORD_INCONSISTENT));
        }
        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)));
        }
Beispiel #4
0
        public async Task <ActionResult> ChangePassword(string UserId, string Password, string NewPassword, string ConfirmPassword)
        {
            if (User.Identity.Name == "Admin")
            {
                ModelState.AddModelError("", (string)"Admin cannot change password");
                return(View("ChangePassword", (object)UserId));
            }
            if (NewPassword == ConfirmPassword)
            {
                LoginApiClient             login    = new LoginApiClient();
                UserStaffInfo              userInfo = WFUtilities.GetUserStaffInfo(UserId);
                RequestResult <BoolResult> res      =
                    await login.ChangeUserPasswordAsync(UserId, Password, NewPassword, userInfo.Country);

                if (!string.IsNullOrEmpty(res.ReturnValue.ret_msg))
                {
                    ModelState.AddModelError("", res.ReturnValue.ret_msg);
                    return(View("ChangePassword", (object)UserId));
                }
                return(RedirectToAction("LogOn"));
            }
            ModelState.AddModelError("", StringResource.PASSWORD_INCONSISTENT);
            return(View("ChangePassword", (object)UserId));
        }