public async Task <MessageModel> Add(User model)
 {
     model.Id         = 0;
     model.CreateTime = DateTime.Now;
     model.Password   = MD5Helper.MD5Encrypt32(model.Password);
     return(new MessageModel(await userServices.Add(model) > 0));
 }
 public void Post([FromBody] User user)
 {
     if (ModelState.IsValid)
     {
         //_context.Users.Add(user);
         //_context.SaveChanges();
         _user.Add(user);
     }
 }
Exemplo n.º 3
0
        // POST: api/Users
        public string Post([FromBody] UserModel user)
        {
            var u = new UserModel()
            {
                Type = user.Type, Email = user.Email
            };

            return(uServices.Add(u));
        }
Exemplo n.º 4
0
        public IActionResult AddUser(AddObjectRequest req)
        {
            string methodName = System.Reflection.MethodInfo.GetCurrentMethod().Name;

            logger.LogInformation($@"{methodName} process is begining.");
            userService.Add(req);
            logger.LogInformation($@"{methodName} process is ended.");
            return(Ok());
        }
Exemplo n.º 5
0
        public IActionResult Add(User user)
        {
            var result = _userServices.Add(user);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Register([FromBody] UserViewModel model)
        {
            if (ModelState.IsValid)
            {
                await userServices.Add(model.FirstName.Trim(), model.LastName.Trim(), model.EmailAddress.Trim(), model.Password.Trim());

                return(Ok());
            }

            return(BadRequest());
        }
Exemplo n.º 7
0
        public IActionResult Add(User entity)
        {
            var result = _servis.Add(entity);

            if (result.Success)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
Exemplo n.º 8
0
        public int Add(JObject value)
        {
            var user = value.ToObject <User>();

            user.Updatetime = DateTime.UtcNow;
            user.Password   = _defaultPassword;

            var r = _userServices.Add(user);

            BindUserRole(r, value);
            return(r);
        }
        public HttpResponseMessage Add(User user)
        {
            try
            {
                int id = userServices.Add(user);

                return(Request.CreateResponse(HttpStatusCode.OK, id));
            }
            catch (Exception e)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, e.Message));
            }
        }
Exemplo n.º 10
0
        public IActionResult Add([FromBody] Users user)
        {
            var Result = _userServices.Add(user);

            if (Result.GetType() == typeof(string))
            {
                return(BadRequest(Result));
            }
            else
            {
                return(Ok(Result));
            }
        }
Exemplo n.º 11
0
        public IDataResult <User> Register(UserForRegisterDto userForRegisterDto, string password)
        {
            byte[] passwordHash, passwordSalt;
            HashingHelper.CreatePasswordHash(password, out passwordHash, out passwordSalt);
            var user = new User
            {
                Email        = userForRegisterDto.Email,
                FirstName    = userForRegisterDto.FirstName,
                LastName     = userForRegisterDto.LastName,
                PasswordHash = passwordHash,
                PasswordSalt = passwordSalt,
                Status       = true
            };

            _userService.Add(user);
            return(new SuccessDataResult <User>(user, "User Registered Successfully"));
        }
Exemplo n.º 12
0
        public async Task <JsonResponse> AddUser([FromBody] AddUserViewModel vm)
        {
            var user = (await _userServices.Query(p => p.UserName == vm.UserName)).SingleOrDefault();

            if (user != null)
            {
                throw new UserOperationException("该帐号已存在");
            }
            vm.Password     = MD5Helper.MD5Encrypt32(vm.Password);
            user            = _mapper.Map <SysUser>(vm);
            user.Creator    = UserIdentity.UserId;
            user.Remark     = "添加用户";
            user.CreateTime = DateTime.Now;
            user.Status     = 1;
            var result = _userServices.Add(user);

            if (result <= 0)
            {
                throw new UserOperationException("添加失败");
            }
            return(new JsonResponse(true));
        }
Exemplo n.º 13
0
        private async Task <List <AllData> > UserInitialAsync(string openId)
        {
            try
            {
                _userServices.GetAdo().BeginTran();

                List <AllData> allDatas = new List <AllData>();

                User newUser = new User
                {
                    OpenId  = openId,
                    Version = 0
                };

                var userId = await _userServices.Add(newUser, false);

                if (userId > 0)
                {
                    Info newInfo = new Info()
                    {
                        OpenId = openId,
                        Name   = "初体验"
                    };

                    var infoId = (await _infoServices.Add(newInfo));

                    if (infoId > 0)
                    {
                        InfoDetail infoDetail0day = new InfoDetail()
                        {
                            InfoId = infoId,
                            Date   = DateTime.Now,
                            Count  = 0,
                            Type   = "日"
                        };

                        List <InfoDetail> newInfoDetails = new List <InfoDetail> {
                            new InfoDetail()
                            {
                                InfoId = infoId,
                                Date   = DateTime.Now.Date,
                                Count  = 0,
                                Type   = "日"
                            },
                            new InfoDetail()
                            {
                                InfoId = infoId,
                                Date   = DateTime.Now.Date.AddDays(100),
                                Count  = 100,
                                Type   = "日"
                            },
                            new InfoDetail()
                            {
                                InfoId = infoId,
                                Date   = DateTime.Now.Date.AddMonths(100),
                                Count  = 100,
                                Type   = "月"
                            },
                            new InfoDetail()
                            {
                                InfoId = infoId,
                                Date   = DateTime.Now.Date.AddYears(100),
                                Count  = 100,
                                Type   = "年"
                            }
                        };

                        bool addSuccess = true;

                        foreach (var infoDetail in newInfoDetails)
                        {
                            var infoDetailId = await _infoDetailServices.Add(infoDetail);

                            if (infoDetailId <= 0)
                            {
                                addSuccess = false;
                                break;
                            }
                        }

                        if (addSuccess)
                        {
                            allDatas.Add(new AllData()
                            {
                                user       = newUser,
                                info       = newInfo,
                                infoDetail = newInfoDetails
                            });
                        }
                    }
                }

                if (allDatas.Count > 0)
                {
                    _userServices.GetAdo().CommitTran();
                }
                else
                {
                    _userServices.GetAdo().RollbackTran();
                }

                return(allDatas);
            }
            catch (Exception ex)
            {
                _userServices.GetAdo().RollbackTran();
                throw ex;
            }
        }
Exemplo n.º 14
0
 public HttpResponseMessage Post([FromBody] /*TblUser*/ App.Core.Models.User value)
 {
     //DBContext.TblUsers.Add(value);
     return(ToJson(/*DBContext.SaveChanges()*/ _userServices.Add(value), _userServices.GetAll().OrderBy(u => u.Id).Count(), _pageSize));
 }
Exemplo n.º 15
0
        public int UsersAdd(UsersInfo usersInfo)
        {
            var useradd = _userServices.Add(usersInfo);

            return(useradd);
        }