//public async Task<IActionResult> OnPostCarOwnerList_DoPostBackAsync(string[] Grid1_fields, int Grid1_pageIndex, string Grid1_sortField, string Grid1_sortDirection,
        //    string ttbSearchMessage, string rblEnableStatus, int ddlGridPageSize, string actionType, int[] deletedRowIDs)
        //{
        //    List<int> ids = new List<int>();
        //    if (deletedRowIDs != null)
        //    {
        //        ids.AddRange(deletedRowIDs);
        //    }

        //    var ttbSearchMessageUI = UIHelper.TwinTriggerBox("ttbSearchMessage");
        //    if (actionType == "trigger1")
        //    {
        //        ttbSearchMessageUI.Text(String.Empty);
        //        ttbSearchMessageUI.ShowTrigger1(false);

        //        // 清空传入的搜索值
        //        ttbSearchMessage = String.Empty;
        //    }
        //    else if (actionType == "trigger2")
        //    {
        //        ttbSearchMessageUI.ShowTrigger1(true);
        //    }
        //    else if (actionType == "delete")
        //    {
        //        // 在操作之前进行权限检查
        //        if (!CheckPower("CoreUserDelete"))
        //        {
        //            CheckPowerFailWithAlert();
        //            return UIHelper.Result();
        //        }

        //        ParkDB.CarOwners.Where(u => ids.Contains(u.ID)).ToList().ForEach(u => ParkDB.CarOwners.Remove(u));
        //        await ParkDB.SaveChangesAsync();
        //    }
        //    else if (actionType == "enable")
        //    {
        //        // 在操作之前进行权限检查
        //        if (!CheckPower("CoreUserEdit"))
        //        {
        //            CheckPowerFailWithAlert();
        //            return UIHelper.Result();
        //        }

        //        ParkDB.CarOwners.Where(u => ids.Contains(u.ID)).ToList().ForEach(u => u.Enabled = true);
        //        await DB.SaveChangesAsync();
        //    }
        //    else if (actionType == "pswd")
        //    {
        //        if (!CheckPower("CoreUserEdit"))
        //        {
        //            CheckPowerFailWithAlert();
        //            return UIHelper.Result();
        //        }

        //        foreach (var owner in ParkDB.CarOwners.Where(u => ids.Contains(u.ID)).ToList())
        //        {
        //            await CarOwnerService.SetPasswordAsync(ParkDB, owner, "123456");
        //        }
        //        ShowNotify("已重设密码为123456");
        //        await DB.SaveChangesAsync();
        //    }
        //    else if (actionType == "disable")
        //    {
        //        // 在操作之前进行权限检查
        //        if (!CheckPower("CoreUserEdit"))
        //        {
        //            CheckPowerFailWithAlert();
        //            return UIHelper.Result();
        //        }

        //        DB.Users.Where(u => ids.Contains(u.ID)).ToList().ForEach(u => u.Enabled = false);
        //        await DB.SaveChangesAsync();
        //    }

        //    return await LoadGrid(Grid1_fields, Grid1_pageIndex, Grid1_sortField, Grid1_sortDirection, ttbSearchMessage, ddlGridPageSize, actionType);
        //}

        protected async override Task OtherPostBackAsync(string actionType, List <int> ids)
        {
            if (actionType == "pswd")
            {
                foreach (var owner in ParkDB.CarOwners.Where(u => ids.Contains(u.ID)).ToList())
                {
                    await CarOwnerService.SetPasswordAsync(ParkDB, owner, "123456");
                }
                ShowNotify("已重设密码为123456");
                await DB.SaveChangesAsync();
            }
        }
Example #2
0
        public async Task <ResponseData <object> > ChangePasswordAsync([FromBody] ChangePasswordRequest request)
        {
            if (!request.IsValid())
            {
                return(new ResponseData <object>()
                {
                    Succeed = false, Message = "用户验证失败"
                });
            }
            CarOwner carOwner = await db.CarOwners.FindAsync(request.UserID);

            if (carOwner == null)
            {
                return(new ResponseData <object>(null, false, "找不到用户"));
            }
            if (carOwner.Password != CarOwnerService.CreateMD5(carOwner.Username + request.OldPassword))
            {
                return(new ResponseData <object>(null, false, "旧密码错误"));
            }
            await CarOwnerService.SetPasswordAsync(db, carOwner, request.NewPassword);

            return(new ResponseData <object>());
        }