public int SaveUser(UserDTO user) { string passwordSalt = CreateSalt(5); string pasword = CreatePasswordHash(user.Password, passwordSalt); Model.Entity.User objUser = new Model.Entity.User(); objUser.UserID = getNewUserId(); objUser.PasswordHash = pasword; objUser.PasswordSalt = passwordSalt; objUser.FirstName = user.FirstName; objUser.MiddleName = user.MiddleName; objUser.LastName = user.LastName; objUser.EmailAddress = user.EmailAddress; objUser.Mobile = user.Mobile; objUser.CreatedOnDate = DateTime.Now; objUser.ModifiedDate = DateTime.Now; _userRepository.Add(objUser); _unitOfWork.Commit(); Model.Entity.UserRoleMapping roleMapping = new Model.Entity.UserRoleMapping(); roleMapping.UserRoleMappingID = getNewUserRoleMappingId(); roleMapping.RoleID = 2; roleMapping.UserID = objUser.UserID; _userRoleMappingRepository.Add(roleMapping); _unitOfWork.Commit(); return(objUser.UserID); }
public int UpdateUser(UserDTO user) { Model.Entity.User objUser = _userRepository.GetById(user.UserID); objUser.FirstName = user.FirstName; objUser.MiddleName = user.MiddleName; objUser.LastName = user.LastName; objUser.EmailAddress = user.EmailAddress; objUser.Mobile = user.Mobile; objUser.ModifiedDate = DateTime.Now; _userRepository.Update(objUser); _unitOfWork.Commit(); Model.Entity.UserRoleMapping userRoleMapping = _userRoleMappingRepository.Get(m => m.UserID == user.UserID); userRoleMapping.RoleID = user.UserRoleID; _userRoleMappingRepository.Update(userRoleMapping); _unitOfWork.Commit(); return(objUser.UserID); }