Exemple #1
0
        public ActionResult Edit(G_UserDTO user)
        {
            var oldUser = this._IG_UserService.GetByKey(user.Id);

            if (user.G_EntityId.HasValue)
            {
                oldUser.G_Entity   = this._IG_EntityService.GetByKey(user.G_EntityId.Value);
                oldUser.G_EntityId = user.G_EntityId.Value;
                this._IG_UserService.Update(new List <G_UserDTO> {
                    oldUser
                });
            }

            var userDetail = this._IG_UserDetailService.GetUserDetailByUserId(user.Id);

            if (userDetail != null)
            {
                userDetail.BankCode = user.G_UserDetail.BankCode;
                this._IG_UserDetailService.Update(new List <G_UserDetailDTO> {
                    userDetail
                });
            }

            return(RedirectToAction("index"));
        }
Exemple #2
0
        public G_UserDTO Create(G_UserDTO dto)
        {
            var user = base.F_Create <G_UserDTO, G_User>(dto
                                                         , _IG_UserRepository
                                                         , dtoAction => { });

            dto.G_UserDetail = dto.G_UserDetail ?? new G_UserDetailDTO()
            {
                Name          = "未设置",
                PersonalPhone = dto.UserName,
                OfficePhone   = dto.UserName
            };
            if (string.IsNullOrWhiteSpace(dto.G_UserDetail.Name))
            {
                dto.G_UserDetail.Name = "未设置";
            }
            var userDetails = new G_UserDetailDTO
            {
                G_UserId      = user.Id,
                PersonalPhone = dto.G_UserDetail.PersonalPhone,
                Name          = dto.G_UserDetail.Name,
                BankCode      = dto.G_UserDetail.BankCode
            };

            var model = this._IG_UserDetailService.Create(userDetails);

            if (dto.UserType == G_UserTypeEnum.CL)
            {
                QRHelper.MakeWithLogo(model.Code);
            }

            return(user);
        }
Exemple #3
0
        protected override void OnAuthentication(System.Web.Mvc.Filters.AuthenticationContext filterContext)
        {
            var allowAnonymous = false;

            //var attributes = new List<dynamic>();

            object[] controllerAttrs = filterContext.ActionDescriptor.ControllerDescriptor.GetCustomAttributes(typeof(AllowAnonymousAttribute), true);

            if (controllerAttrs != null)
            {
                controllerAttrs.ToList().ForEach(item =>
                {
                    if (item is AllowAnonymousAttribute)
                    {
                        allowAnonymous = true;
                    }
                });
            }

            object[] actionAttrs = filterContext.ActionDescriptor.GetCustomAttributes(typeof(AllowAnonymousAttribute), true);
            if (actionAttrs != null)
            {
                actionAttrs.ToList().ForEach(item =>
                {
                    if (item is AllowAnonymousAttribute)
                    {
                        allowAnonymous = true;
                    }
                });
            }

            //var enumerator = attributes.GetEnumerator();

            //while (enumerator.MoveNext())
            //{
            //    if (enumerator.Current is AllowAnonymousAttribute)
            //        allowAnonymous = true;
            //}

            var user = System.Web.HttpContext.Current.Session["User"] as G_UserDTO;

            if (user == null && !allowAnonymous)
            {
                System.Web.HttpContext.Current.Response.Redirect("/jiajudai/login", true);
            }
            //user = new G_UserDTO();
            if (user != null)
            {
                this.User        = user;
                ViewBag.User     = user;
                ViewBag.UserName = user.UserName;
            }

            base.OnAuthentication(filterContext);
        }
Exemple #4
0
        public G_UserDTO Login(G_UserDTO user)
        {
            user.Password = user.Password.ToMD5String();
            var model = Mapper.Map <G_User, G_UserDTO>(
                this._IG_UserRepository.Login(Mapper.Map <G_UserDTO, G_User>(user))
                );

            if (model != null)
            {
                model.G_UserDetail = this._IG_UserDetailService.GetUserDetailByUserId(model.Id);
            }
            return(model);
        }
Exemple #5
0
        public ActionResult Create(G_UserDTO user)
        {
            user.Password = GlobalMessage.API_InitPassword.ToMD5String();
            if (string.IsNullOrWhiteSpace(user.UserName))
            {
                this.DataBind();
                ModelState.AddModelError("username", "账号未设置");
                return(RedirectToAction("create"));
            }
            var userDetails = user.G_UserDetail;

            if (user.UserType == G_UserTypeEnum.BC ||
                user.UserType == G_UserTypeEnum.BM)
            {
                if (userDetails == null ||
                    string.IsNullOrWhiteSpace(userDetails.BankCode))
                {
                    this.DataBind();
                    ModelState.AddModelError("bank", "所属银行未设置");
                    return(RedirectToAction("create"));
                }
            }
            else
            {
                if (user.G_UserDetail != null)
                {
                    user.G_UserDetail.BankCode = "";
                }
            }

            user = this._IG_UserService.Create(user);

            if (user.IsAdmin)
            {
                if (user.G_EntityId != null)
                {
                    var entity = this._IG_EntityService.GetByKey(user.G_EntityId.Value);
                    entity.UserId = user.Id;
                    this._IG_EntityService.Update(new List <G_EntityDTO> {
                        entity
                    });
                }
            }


            return(RedirectToAction("index"));
        }
Exemple #6
0
        public ActionResult Register(G_UserDTO user)
        {
            if (string.IsNullOrWhiteSpace(user.UserName) ||
                string.IsNullOrWhiteSpace(user.Password) ||
                (user.Password.Length < 6 && user.Password.Length > 18))
            {
                return(Json(new MessageResult {
                    Status = false, Message = "资料输入有误"
                }, JsonRequestBehavior.AllowGet));
            }

            var hasUserName = this._IG_UserService.GetUserByUserName(user.UserName) != null;

            if (hasUserName)
            {
                return(Json(new MessageResult {
                    Status = hasUserName, Message = hasUserName ? "手机号码已存在" : "用户名不存在"
                }, JsonRequestBehavior.AllowGet));
            }
            string password = user.Password;

            user.Id       = user.CreatedBy = user.ModifiedBy = Guid.NewGuid();
            user.Password = user.Password.ToMD5String();
            user.UserType = Ingenious.Infrastructure.Enum.G_UserTypeEnum.US;
            if (user.G_UserDetail == null)
            {
                user.G_UserDetail = new G_UserDetailDTO();
            }
            user.G_UserDetail.PersonalPhone = user.UserName;
            user.G_UserDetail.Name          = "未设置";
            user.G_UserDetail.NickName      = "未设置";

            user = this._IG_UserService.Create(user);
            this.Login(user.UserName, password);
            return(Json(new MessageResult {
                Status = true, Message = "注册成功"
            }, JsonRequestBehavior.AllowGet));
        }