public int?AddUser(string name, string birthday, byte[] userPhoto) { if (Validation.Validation.IsEmptyStrings(name, birthday)) { throw new ArgumentNullException(nameof(name), "Parameters must be not null"); } if (DateTime.TryParse(birthday, out DateTime rightBirthday)) { int age = SetAge(rightBirthday); if (!Validation.Validation.IsRightAge(age)) { throw new ArgumentException(nameof(birthday), "Incorrect date of birthday"); } var newUser = new User { Name = name, Birthday = rightBirthday, Age = SetAge(rightBirthday), UserPhoto = userPhoto }; return(_userDao.AddUser(newUser)); } else { throw new ArgumentException(nameof(birthday), "Incorrect date of birthday"); } }
public int SetUser(User user) { _logger.Info($"BLL.{nameof(UserBll)}.{nameof(SetUser)}: Retention of the user"); if (user.Role != null) { _logger.Info($"BLL.{nameof(UserBll)}.{nameof(SetUser)}: Role discovered"); user.Role.Id = _roleBll.SetRole(user.Role); } else { _logger.Info($"BLL.{nameof(UserBll)}.{nameof(SetUser)}: Role not discovered"); } if (user.Id != null) { int id = _userDao.ChangeUser(user); _logger.Info($"BLL.{nameof(UserBll)}.{nameof(SetUser)}: User id = {id} changed"); return(id); } else { int id = _userDao.AddUser(user); _logger.Info($"BLL.{nameof(UserBll)}.{nameof(SetUser)}: User id = {id} added"); return(id); } }
public bool AddUser(User user) { _userDao.AddUser(user); Logger.Log($"Added user {user.Id}"); return(true); }
public bool AddUser(User user) { _userDao.AddUser(user); logging.WriteLoggingInFile($"Добавили пользователя {user.UserId}"); return(true); }
public bool AddUser(string user_name, string user_pass) { if (user_dao.GetUserByName(user_name) != null) { return(false); } return(user_dao.AddUser(user_name, user_pass)); }
public int AddUser(User user) { byte[] data = user.Password.Select(x => (byte)x).ToArray(); byte[] result; using (SHA512 shaM = SHA512.Create()) { result = shaM.ComputeHash(data); } return(_userDao.AddUser(user, result.ToList())); }
public bool AddUser(User user) { if (!UserExists(user)) { return(dao.AddUser(user)); } else { throw new Exception(Resources.ErrorUserAlreadyExist); } }
public string AddUser(UserVO inuser) { string status = ""; try { status = userDao.AddUser(inuser); } catch (CustomException ex) { throw ex; } return(status); }
public User AddUser(User u, User user) { if (u != null) { if (UserDao.GetOneByLogin(u.Login) == null) { User o = UserDao.AddUser(u); if (o != null) { logger.Info(user.Login + " a ajouter l'utilisateur " + o.Login); return(o); } } } return(null); }
public void AddUserTest() { _dao.AddUser(new UserModel { Name = "Furutate", Age = 44, MailAddress = "*****@*****.**", }); // 追加されたか確認する var command = _context.CreateCommand(); command.CommandText = "SELECT COUNT(*) FROM USER;"; Assert.AreEqual(4L, command.ExecuteScalar()); }
//todo unitested public int AddUser(User user) { var checkUser = _userDao.GetUser(user.UserName); //判断用户名是否存在 if (!checkUser.IsNullOrEmpty()) { throw new BussinessException(ERROR_USERNAME_EXIST); } user.Password = DEncrypt.Encrypt(user.Password, Key); Object obj = _userDao.AddUser(GetUserPoFromUser(user)); return((int)obj); }
public bool AddUser(string name, string birthday) { if (!String.IsNullOrEmpty(name)) { var rightBirthday = DateTime.Parse(birthday); var newUser = new User { IdUser = SetIdUser(), Name = name, Birthday = rightBirthday, Age = SetAge(rightBirthday) }; _userDao.AddUser(newUser); return(true); } return(false); }
public async Task MakeOrder( UserDto userDto, List <OrderedProductDto> orderedProducts, decimal price, decimal advance) { var user = await _userDao.GetByEmail(userDto.Email); if (user == null) { user = userDto; user.CreationSource = UserCreationSource.MadeOrder; user.SubscriptionOptions = SubscriptionOption.All; user.Id = await _userDao.AddUser(user); } ; var tasks = orderedProducts.Select(op => _modelParser.ParseFromSku(op.Sku)); var models = (await Task.WhenAll(tasks)).GroupBy(m => m.Sku).ToDictionary(m => m.Key, m => m.First()); foreach (var prod in orderedProducts) { prod.SerializedProduct = JsonConvert.SerializeObject(models[prod.Sku], Formatting.Indented); prod.ProductLink = $"https://ujin.org/ua/model/{models[prod.Sku].Identifier}?sku={prod.Sku}"; } var order = new OrderDto { UserId = user.Id, Price = price, Advance = advance, OrderedProducts = orderedProducts }; await _orderDao.AddOrder(order); await _mailSender.SendMessage(new SimpleMail { From = _mailSettings.SupportMail, To = _mailSettings.MailTo, Subject = "Ujin jewelry: new order", Body = GenerateMailMessage(order, user) }); }
public async Task <IActionResult> CreateUser([FromBody] UserImDto userIm) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } User user = _mapper.Map <User>(userIm); user.TimeCreated = DateTime.Now; user.CreatedQuizzes = null; var result = await _userDAO.AddUser(user, user.Password); if (!result.Succeeded) { return(new BadRequestObjectResult(ErrorsForModelState.AddErrorsToModelState(result, ModelState))); } return(new OkObjectResult("User succesfully created")); }
public void AddUser(User user) { userDao.AddUser(user); }
public async Task AddUser(User user, string role) { await _userDao.AddUser(user, role); }
public User AddUser(User user) { return(_userDao.AddUser(user)); }
public bool AddUser(string name, DateTime dob) { users_dao.AddUser(name, dob); return(true); }
public void AddUser(string name, DateTime dateOfBirth, IEnumerable <string> titles) { _userDao.AddUser(name, dateOfBirth, titles); }
public int AddUser(User user) { user.RoleId = roleDao.GetRole(Role.VALUE.USER.ToString()).Id; user.StatusId = statusDao.GetStatus(Status.VALUE.USER_ACTIVE.ToString()).Id; return(userDao.AddUser(user)); }
public bool AddUser(User user) { _userDao.AddUser(user); return(true); }
public void AssertThatAddUserIsCalled() { _userDao.AddUser(_user, User.UserRole); _collection.Received().InsertOneAsync(Arg.Any <User>()); }
/// <summary> /// Method for adding user using userDao class /// </summary> /// <param name="user"></param> /// <returns></returns> public Task <User> AddUser(User user) { return(_userDao.AddUser(user)); }