Exemplo n.º 1
0
 public StatusEnum.Status UpdateUser(UserModel model)
 {
     StatusEnum.Status status = StatusEnum.Status.Success;
     try
     {
         PASCore_Users user = _userRepository.GetByID(model.UserId);
         user.UserName          = model.UserName;
         user.TelMobile         = model.TelMobile;
         user.TelMainTwo        = model.TelMainTwo;
         user.TelMainOne        = model.TelMainOne;
         user.Telex             = model.Telex;
         user.Prefix            = model.Prefix;
         user.Password          = model.Password;
         user.OfficeId          = Guid.NewGuid();
         user.ModifiedDateTime  = null;
         user.MiddleName        = model.MiddleName;
         user.LastName          = model.LastName;
         user.LastLoginDateTime = null;
         user.IsDeleted         = false;
         user.IsActive          = true;
         user.FirstName         = model.FirstName;
         user.EntityId          = model.EntityId;
         user.EmailAddress      = model.emailAddress;
         user.DeletedDateTime   = null;
         user.CreatedDateTime   = DateTime.UtcNow;
         _userRepository.Update(user);
         _userRepository.SaveChanges();
     }
     catch (Exception ex)
     {
         status = StatusEnum.Status.Fail;
     }
     return(status);
 }
Exemplo n.º 2
0
 public StatusEnum.Status SaveUser(UserModel model)
 {
     StatusEnum.Status status = StatusEnum.Status.Success;
     try
     {
         _user                   = new PASCore_Users();
         _user.Id                = Guid.NewGuid();
         _user.UserName          = model.UserName;
         _user.TelMobile         = model.TelMobile;
         _user.TelMainTwo        = model.TelMainTwo;
         _user.TelMainOne        = model.TelMainOne;
         _user.Telex             = model.Telex;
         _user.Prefix            = model.Prefix;
         _user.Password          = model.Password;
         _user.OfficeId          = Guid.NewGuid();
         _user.ModifiedDateTime  = null;
         _user.MiddleName        = model.MiddleName;
         _user.LastName          = model.LastName;
         _user.LastLoginDateTime = null;
         _user.IsDeleted         = false;
         _user.IsActive          = true;
         _user.FirstName         = model.FirstName;
         _user.EntityId          = model.EntityId;
         _user.EmailAddress      = model.emailAddress;
         _user.DeletedDateTime   = null;
         _user.CreatedDateTime   = DateTime.UtcNow;
         _userRepository.Create(_user);
         _userRepository.SaveChanges();
         if (_user.Id != null)
         {
             if (model.UserRole.Length > 0)
             {
                 foreach (var roles in model.UserRole)
                 {
                     Guid roleId = new Guid(roles);
                     _userRoles = new PASCore_UserRoles()
                     {
                         RoleId = roleId,
                         UserId = _user.Id
                     };
                     _userRoleRepository.Create(_userRoles);
                 }
                 _userRoleRepository.SaveChanges();
             }
         }
     }
     catch (Exception)
     {
         status = StatusEnum.Status.Fail;
     }
     return(status);
 }
Exemplo n.º 3
0
 public StatusEnum.Status DeleteUser(Guid id)
 {
     StatusEnum.Status status = StatusEnum.Status.Success;
     try
     {
         PASCore_Users userDelete = _userRepository.GetByID(id);
         userDelete.IsDeleted = true;
         _userRepository.Update(userDelete);
         _userRepository.SaveChanges();
     }
     catch (Exception)
     {
         status = StatusEnum.Status.Fail;
     }
     return(status);
 }