Exemplo n.º 1
0
        public JsonResult DoRegist(Core.Members input)
        {
            ResultDto <int> result = new ResultDto <int>();

            try
            {
                MembersService ObjServ = new MembersService();
                var            item1   = ObjServ.Reposity.GetAllList(o => o.UserName == input.UserName).Count();
                var            item2   = ObjServ.Reposity.GetAllList(o => o.Mobile == input.Mobile && o.Mobile != null).Count();
                var            item3   = ObjServ.Reposity.GetAllList(o => o.UserID == input.UserID && o.UserID != "00").Count();
                if (item1 > 0)
                {
                    result.code    = 500;
                    result.message = "用户名已经存在";
                }
                else if (item2 > 0)
                {
                    result.code    = 500;
                    result.message = "手机号已经存在";
                }
                else if (item3 > 0)
                {
                    result.code    = 500;
                    result.message = "身份证号已经存在";
                }
                else if (input.Phone2 != Session["VeryCode"].ToString())
                {
                    result.code    = 500;
                    result.message = "手机验证码错误";
                }
                else
                {
                    Random rand = new Random();
                    int    rank = rand.Next(1, 8);
                    input.Photo        = "/Content/dist/img/user" + rank.ToString() + ".jpg";
                    input.Password     = MD5(input.Password);
                    input.CreationTime = DateTime.Now;
                    input.TenantId     = tenant.Id;
                    input.Phone2       = "";
                    ObjServ.Reposity.Insert(input);
                    result.code    = 100;
                    result.message = "ok";
                }
                ObjServ.Dispose();
            }
            catch (Exception ex)
            {
                result.code    = 500;
                result.message = ex.Message;
            }
            return(Json(result));
        }
Exemplo n.º 2
0
        public JsonResult GetMember(int id = 0)
        {
            Core.Members   model   = new Core.Members();
            MembersService ObjServ = new MembersService();
            var            result  = ObjServ.Reposity.Get(id);

            if (result != null)
            {
                model = result;
            }
            else
            {
                model.TenantId = tenant.Id;
            }
            ObjServ.Dispose();
            return(Json(model));
        }
Exemplo n.º 3
0
        public JsonResult Update(Core.Members input)
        {
            ResultDto <int> result = new ResultDto <int>();

            try
            {
                MembersService ObjServ     = new MembersService();
                MembersService ObjServRead = new MembersService();
                var            item1       = ObjServ.Reposity.GetAllList(o => o.UserName == input.UserName && o.Id != MemberId).Count();
                var            item2       = ObjServ.Reposity.GetAllList(o => o.Mobile == input.Mobile && o.Id != MemberId).Count();
                var            item3       = ObjServ.Reposity.GetAllList(o => o.UserID == input.UserID && o.Id != MemberId && o.UserID != "00").Count();
                if (item1 > 0)
                {
                    result.code    = 500;
                    result.message = "用户名已经存在";
                }
                else if (item2 > 0)
                {
                    result.code    = 500;
                    result.message = "手机号已经存在";
                }
                else if (item3 > 0)
                {
                    result.code    = 500;
                    result.message = "身份证号已经存在";
                }
                else
                {
                    var model = ObjServRead.Reposity.Get(input.Id);
                    input.Password     = model.Password;
                    input.CreationTime = model.CreationTime;
                    ObjServ.Reposity.Update(input);
                    result.code    = 100;
                    result.message = "ok";
                }
                ObjServ.Dispose();
                ObjServRead.Dispose();
            }
            catch (Exception ex)
            {
                result.code    = 500;
                result.message = ex.Message;
            }
            return(Json(result));
        }
Exemplo n.º 4
0
        public JsonResult GetModel()
        {
            Core.Members   model   = new Core.Members();
            MembersService ObjServ = new MembersService();
            var            result  = ObjServ.Reposity.Get(MemberId);

            if (result != null)
            {
                model = result;
            }
            else
            {
                model.TenantId = tenant.Id;
            }
            var entity = Mapper.Map <Dto.MemberDto>(model);

            ObjServ.Dispose();
            return(Json(model));
        }