Example #1
0
        public ActionResult <AuthenticationData> Post([FromBody] RegisterModel registerModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!registerModel.IsValid)
            {
                return(BadRequest(new { Error = "Invalid fields" }));
            }

            if (!_userAccountRepository.IsUsernameUnique(registerModel.Username))
            {
                return(BadRequest(new { Error = "Username already exists" }));
            }

            var userAccount = new UserAccount
            {
                Username     = registerModel.Username,
                PasswordHash = _authService.GetPasswordHash(registerModel.Password),
                Name         = registerModel.Name
            };

            _userAccountRepository.Add(userAccount);
            _userAccountRepository.Commit();

            return(_authService.GetAuthenticationData(userAccount.Id));
        }
Example #2
0
 private void RegistUserAccount(UserInfo user, string password)
 {
     try
     {
         UserAccount account = new UserAccount();
         account.UserName = user.UserName;
         account.Password = password.MD5();
         account.UserID   = user.Id;
         _userAccountRepository.Add(account);
     }
     catch (Exception ex)
     {
     }
 }
Example #3
0
 private void RegistUserAccount(UserInfo user, string password)
 {
     try
     {
         UserAccount account = new UserAccount();
         account.UserName = user.UserName;
         account.Password = ConvertPassword(password);
         account.UserID   = user.Id;
         _userAccountRepository.Add(account);
         _unitOfWork.SaveChanges();
     }
     catch (Exception ex)
     {
     }
 }
        public ActionResult <UserAccount> PostUserAccount(RegisterUserAccountDto registerUserAccountDto)
        {
            if (!ModelState.IsValid)
            {
                throw new ApiException(ModelState.AllErrors());
            }

            var userAccountGuid = Guid.NewGuid();
            var userAccount     = new UserAccount
            {
                //Guid = userAccountGuid,
                Email        = registerUserAccountDto.Email,
                PasswordHash = registerUserAccountDto.Password.GetHashCode().ToString() // TODO Add Actual Hashing Algorithm
            };

            _userAccountRepository.Add(userAccount);
            _unitOfWork.Commit();

            return(CreatedAtAction("GetUserAccount", new { id = userAccountGuid }, userAccount));
        }
Example #5
0
        public UserAccount Create(MeetupMember member)
        {
            var user = new UserAccount
            {
                Bio            = member.bio,
                IsAdmin        = false,
                IsDeleted      = false,
                Name           = member.name,
                MeetupMemberId = member.id,
            };

            if (member.Photo != null)
            {
                user.ProfilePic  = member.Photo.photo_link;
                user.ProfileThmb = member.Photo.thumb_link;
            }

            _userAccountRepository.Add(user);
            return(user);
        }
        /// <summary>
        /// Add new Tax value
        /// </summary>
        /// <param name="obj">Tax value</param>
        /// <returns></returns>
        public ApiResponseViewModel Add(UserAccount obj)
        {
            var result   = new UserAccount();
            var response = new ApiResponseViewModel
            {
                Code    = CommonConstants.ApiResponseSuccessCode,
                Message = null,
                Result  = null
            };

            try
            {
                result = _userAccountRepository.Add(obj);
                _unitOfWork.Commit();
                response.Message = CommonConstants.AddSuccess;
                response.Result  = result;
            }
            catch (Exception ex)
            {
                response.Code    = CommonConstants.ApiResponseExceptionCode;
                response.Message = CommonConstants.ErrorMessage + " " + ex.Message;
            }
            return(response);
        }
        public void Add(UserAccount entity)

        {
            UserRepo.Add(entity);
            SaveChanges();
        }
 public void Add(TAccount item)
 {
     RaiseValidation();
     inner.Add(item);
     RaiseEvents();
 }
 public void Add(UserAccount userAccount)
 {
     _userAccountRepository.Add(userAccount);
 }