Esempio n. 1
0
        public ActionResult Create()
        {
            UserVM vm = new UserVM()
            {
                UserType = 2
            };

            //ViewBag.Roles = ApplicationConfigHelper.GetRoles().Select(s => new SelectListItem() { Value = s.ID.ToString(), Text = s.Name });
            ViewBag.Roles = new RoleService().GetRoleInfo(new GetRoleByProjectIDRequest()
            {
                ProjectID = base.UserInfo.ProjectID
            }).Result
                            .Select(pr => new SelectListItem()
            {
                Text = pr.Name, Value = pr.ProjectRoleID.ToString()
            });

            ViewBag.Shippers = ApplicationConfigHelper.GetProjectShippers(base.UserInfo.ProjectID).Select(s => new SelectListItem()
            {
                Value = s.ShipperID.ToString(), Text = s.Name
            });
            ViewBag.Customers = ApplicationConfigHelper.GetProjectCustomers(base.UserInfo.ProjectID).Select(s => new SelectListItem()
            {
                Value = s.CustomerID.ToString(), Text = s.Name
            });
            ViewBag.WareHouse = ApplicationConfigHelper.GetWarehouseList().Select(s => new SelectListItem()
            {
                Value = s.ID.ToString(), Text = s.WarehouseName
            });

            return(View(vm));
        }
Esempio n. 2
0
        public ActionResult Edit(UserVM user)
        {
            if (ModelState.IsValid)
            {
                var response = new UserService().EditUser(new UserRequest()
                {
                    Name                = user.Name,
                    UserName            = base.UserInfo.Name,
                    ProjectId           = base.UserInfo.ProjectID,
                    ProjectRoleId       = user.ProjectRoleID,
                    DisplayName         = user.DisplayName,
                    State               = user.State,
                    Sex                 = user.Sex,
                    Email               = user.Email,
                    UserType            = user.UserType,
                    CustomerOrShipperID = user.UserType == 0 ? user.CustomerID ?? 0 : user.UserType == 1 ? user.ShipperID ?? 0 : 0,
                    Mobile              = user.Mobile,
                    Tel                 = user.Tel,
                    ID       = user.ID,
                    RuleArea = ApplicationConfigHelper.GetRegions().Where(a => a.Name == user.RuleAreaName).Select(a => a.ID).FirstOrDefault().ToString()
                });
                ViewBag.Shippers = ApplicationConfigHelper.GetProjectShippers(base.UserInfo.ProjectID).Select(s => new SelectListItem()
                {
                    Value = s.ShipperID.ToString(), Text = s.Name
                });
                ViewBag.Customers = ApplicationConfigHelper.GetProjectCustomers(base.UserInfo.ProjectID).Select(s => new SelectListItem()
                {
                    Value = s.CustomerID.ToString(), Text = s.Name
                });
                ViewBag.Roles = new RoleService().GetRoleInfo(new GetRoleByProjectIDRequest()
                {
                    ProjectID = base.UserInfo.ProjectID
                }).Result.Select(pr => new SelectListItem()
                {
                    Text = pr.Name, Value = pr.ProjectRoleID.ToString()
                });

                if (response.IsSuccess)
                {
                    user.RuleAreaName = ApplicationConfigHelper.GetRegions().Where(a => a.ID.ToString() == user.RuleArea).Select(a => a.Name).FirstOrDefault();
                    ApplicationConfigHelper.RefreshApplicationUsers();
                    ApplicationConfigHelper.RefreshProjectUserRole();
                    ViewBag.Message = "更新成功";
                }
                else
                {
                    ViewBag.Message = "更新失败";
                }
            }
            return(View(user));
        }
Esempio n. 3
0
        public ActionResult Create(UserVM user)
        {
            string userName = Session["Name"].ToString();
            // string wareId = Request.Form["cWarehouse"].ToString();
            string RoleId = Request.Form["cRole"].ToString();

            if (ModelState.IsValid)
            {
                UserRequest request = new UserRequest()
                {
                    Name        = user.Name,
                    DisplayName = user.DisplayName,
                    //Password = Runbow.TWS.Common.AES.Encrypt(Constants.PASSWORD),
                    Password            = Constants.PASSWORD,
                    Sex                 = user.Sex,
                    State               = true,
                    Tel                 = user.Tel,
                    Mobile              = user.Mobile,
                    Email               = user.Email,
                    UserType            = user.UserType,
                    RuleArea            = user.RuleArea,
                    CustomerOrShipperID = user.UserType == 0 ? user.CustomerID ?? 0 : user.UserType == 1 ? user.ShipperID ?? 0 : 0
                };

                Response <long> response = new UserService().AddUser2(request, userName, RoleId, base.UserInfo.ProjectID.ToString());

                if (response.IsSuccess)
                {
                    ApplicationConfigHelper.RefreshApplicationUsers();
                    ApplicationConfigHelper.RefreshProjectUserRole();
                    ApplicationConfigHelper.RefreshCustomers();
                    return(RedirectToAction("Edit", new { ID = response.Result, message = "操作成功!" }));
                }
                else
                {
                    //ViewBag.Roles = ApplicationConfigHelper.GetApplicationRoles().Select(s => new SelectListItem() { Value = s.ID.ToString(), Text = s.Name });
                    ViewBag.Roles = new RoleService().GetRoleInfo(new GetRoleByProjectIDRequest()
                    {
                        ProjectID = base.UserInfo.ProjectID
                    }).Result
                                    .Select(pr => new SelectListItem()
                    {
                        Text = pr.Name, Value = pr.ProjectRoleID.ToString()
                    });
                    ViewBag.Shippers = ApplicationConfigHelper.GetProjectShippers(base.UserInfo.ProjectID).Select(s => new SelectListItem()
                    {
                        Value = s.ShipperID.ToString(), Text = s.Name
                    });
                    ViewBag.Customers = ApplicationConfigHelper.GetProjectCustomers(base.UserInfo.ProjectID).Select(s => new SelectListItem()
                    {
                        Value = s.CustomerID.ToString(), Text = s.Name
                    });
                    ViewBag.WareHouse = ApplicationConfigHelper.GetWarehouseList().Select(s => new SelectListItem()
                    {
                        Value = s.ID.ToString(), Text = s.WarehouseName
                    });

                    if (response.Result == -1)
                    {
                        ViewBag.Message = "已存在此用户,请更换用户名";
                    }
                    else
                    {
                        ViewBag.Message = "系统出错!";
                    }
                }
            }

            return(View(user));
        }