예제 #1
0
 public BusinessEntities.UserEntity CreateUser(BusinessEntities.UserEntity userEntity)
 {
     if (userEntity == null)
     {
         return(null);
     }
     using (var scope = new TransactionScope())
     {
         var user = Mapper.Map <UserEntity, User>(userEntity);
         _unitOfWork.UserRepository.Insert(user);
         _unitOfWork.Save();
         scope.Complete();
         userEntity.id = user.Id;
         return(userEntity);
     }
 }
예제 #2
0
 /// <summary>
 /// Creates a User
 /// </summary>
 /// <param name="UserEntity"></param>
 /// <returns></returns>
 public long CreateUser(UserEntity UserEntity)
 {
     using (var scope = new TransactionScope())
     {
         var User = new User
         {
             FName = UserEntity.FName,
             LName = UserEntity.LName,
             Email = UserEntity.Email,
             Password = UserEntity.Password
         };
         _unitOfWork.UserRepository.Insert(User);
         _unitOfWork.Save();
         scope.Complete();
         return User.Id;
     }
 }
예제 #3
0
        public ActionResult Register(UserEntity userData)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    long userId = _userServices.CreateUser(userData);
                    if(userId != 0)
                    {
                        return RedirectToAction("Index", "Home");
                    }
                    else
                    {
                        ModelState.AddModelError("", "Error occur while creating user!");
                    }

                }
                catch (Exception EX)
                {
                    ModelState.AddModelError("", "Error occur while creating user!");
                }

            }
            return View();
        }
예제 #4
0
 /// <summary>
 /// Updates a User
 /// </summary>
 /// <param name="UserId"></param>
 /// <param name="UserEntity"></param>
 /// <returns></returns>
 public bool UpdateUser(int UserId, UserEntity UserEntity)
 {
     var success = false;
     if (UserEntity != null)
     {
         using (var scope = new TransactionScope())
         {
             var User = _unitOfWork.UserRepository.GetByID(UserId);
             if (User != null)
             {
                 User.FName = UserEntity.FName;
                 User.LName = UserEntity.LName;
                 User.Email = UserEntity.Email;
                 User.Password = UserEntity.Password;
                 _unitOfWork.UserRepository.Update(User);
                 _unitOfWork.Save();
                 scope.Complete();
                 success = true;
             }
         }
     }
     return success;
 }
예제 #5
0
 public ActionResult Register(UserEntity userData)
 {
     return RedirectToAction("Index", "Home");
 }