Ejemplo n.º 1
0
        public Response <SecurityUserDto> SaveCheck(SecurityUserDto securityUserDto)
        {
            Response <SecurityUserDto> response = new Response <SecurityUserDto>();

            if (securityUserDto == null)
            {
                response.HasErrors = true;
                response.FieldErrors.Add(new FieldError()
                {
                    ErrorMessage = "The entry you trying to save does not exist."
                });

                return(response);
            }

            switch (securityUserDto.CrudOperation)
            {
            case CrudOperations.Create:
                return(CreateUserCheck(securityUserDto));

            case CrudOperations.Update:
                return(UpdateUserCheck(securityUserDto));

            default:
                throw new ArgumentException("Invalid crud operation.");
            }
        }
        public SecurityUserViewModel MapToPatientAddressViewModel(SecurityUserDto securityUserDto)
        {
            if (securityUserDto == null)
            {
                return(null);
            }

            SecurityUserViewModel securityUserViewModel = new SecurityUserViewModel();

            securityUserViewModel.SecurityUserId      = securityUserDto.SecurityUserId;
            securityUserViewModel.UserName            = securityUserDto.UserName;
            securityUserViewModel.Title               = securityUserDto.Title;
            securityUserViewModel.Initials            = securityUserDto.Initials;
            securityUserViewModel.FirstName           = securityUserDto.FirstName;
            securityUserViewModel.LastName            = securityUserDto.LastName;
            securityUserViewModel.IDNumber            = securityUserDto.IDNumber;
            securityUserViewModel.BirthDate           = securityUserDto.BirthDate;
            securityUserViewModel.Gender              = securityUserDto.Gender;
            securityUserViewModel.WorkTelephoneCode   = securityUserDto.WorkTelephoneCode;
            securityUserViewModel.WorkTelephoneNumber = securityUserDto.WorkTelephoneNumber;
            securityUserViewModel.FaxCode             = securityUserDto.FaxCode;
            securityUserViewModel.FaxNumber           = securityUserDto.FaxNumber;
            securityUserViewModel.MobileNumber        = securityUserDto.MobileNumber;
            securityUserViewModel.EmailAddress        = securityUserDto.EmailAddress;
            securityUserViewModel.EmployeeNumber      = securityUserDto.EmployeeNumber;
            securityUserViewModel.DisabledDate        = securityUserDto.DisabledDate;

            if (securityUserDto.SecurityUserRoles != null && securityUserDto.SecurityUserRoles.Count > 0)
            {
                securityUserViewModel.SecurityUserRoleId = securityUserDto.SecurityUserRoles.FirstOrDefault().SecurityUserRoleId.Value;
            }
            return(securityUserViewModel);
        }
Ejemplo n.º 3
0
        public SecurityUserViewModel MapToPatientAddressViewModel(SecurityUserDto securityUserDto)
        {
            if (securityUserDto == null)
            {
                return(null);
            }

            SecurityUserViewModel securityUserViewModel = new SecurityUserViewModel();

            securityUserViewModel.SecurityUserId      = securityUserDto.SecurityUserId;
            securityUserViewModel.UserName            = securityUserDto.UserName;
            securityUserViewModel.Title               = securityUserDto.Title;
            securityUserViewModel.Initials            = securityUserDto.Initials;
            securityUserViewModel.FirstName           = securityUserDto.FirstName;
            securityUserViewModel.LastName            = securityUserDto.LastName;
            securityUserViewModel.IDNumber            = securityUserDto.IDNumber;
            securityUserViewModel.BirthDate           = securityUserDto.BirthDate;
            securityUserViewModel.Gender              = securityUserDto.Gender;
            securityUserViewModel.WorkTelephoneCode   = securityUserDto.WorkTelephoneCode;
            securityUserViewModel.WorkTelephoneNumber = securityUserDto.WorkTelephoneNumber;
            securityUserViewModel.FaxCode             = securityUserDto.FaxCode;
            securityUserViewModel.FaxNumber           = securityUserDto.FaxNumber;
            securityUserViewModel.MobileNumber        = securityUserDto.MobileNumber;
            securityUserViewModel.EmailAddress        = securityUserDto.EmailAddress;
            securityUserViewModel.EmployeeNumber      = securityUserDto.EmployeeNumber;
            securityUserViewModel.DisabledDate        = securityUserDto.DisabledDate;
            securityUserViewModel.PasswordSalt        = securityUserDto.PasswordSalt;
            securityUserViewModel.Password            = securityUserDto.Password;
            securityUserViewModel.FirstTimeLogInInd   = securityUserDto.FirstTimeLogInInd;

            return(securityUserViewModel);
        }
Ejemplo n.º 4
0
        public Response <SecurityUserDto> SaveUser(SecurityUserDto securityUserDto)
        {
            Response <SecurityUserDto> response = _SecurityUserBusinessRules.SaveCheck(securityUserDto);

            if (response.HasErrors)
            {
                return(response);
            }

            switch (securityUserDto.CrudOperation)
            {
            case CrudOperations.Create:
                response.Model = Create(securityUserDto);
                break;

            case CrudOperations.Update:
                response.Model = Update(securityUserDto);
                break;

            default:
                throw new ArgumentException("Invalid crud operation.");
            }

            return(response);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Determines whether the specified role is granted to execute the specified task.
 /// </summary>
 /// <param name="to">The level of authorisatio needed to execute the role.</param>
 /// <param name="assignedRole">The assigned role.</param>
 /// <returns>
 ///   <c>true</c> if the specified assigned role is granted; otherwise, <c>false</c>.
 /// </returns>
 public bool IsGranted(string to, SecurityUserDto user)
 {
     if (to == To.Everyone)
     {
         return(true);
     }
     else if (user == null)
     {
         return(false);
     }
     else if (user.AssignedRole == null && !user.IsSuperAdmin)
     {
         return(false);
     }
     else if (user.IsSuperAdmin)
     {
         return(true);
     }
     else
     {
         return((from task in user.AssignedRole.Tasks
                 where task.RefName.ToLower() == to
                 select task).ToList().Count() > 0);
     }
 }
Ejemplo n.º 6
0
        private SecurityUserDto Update(SecurityUserDto securityUserDto)
        {
            SecurityUserDto updatedSecurityUserDto = null;

            using (TransactionScope scope = new TransactionScope())
            {
                using (UnitOfWork unitOfWork = new UnitOfWork())
                {
                    SecurityUser securityUser = unitOfWork.SecurityUserRepository.GetByID(p => p.SecurityUserId == securityUserDto.SecurityUserId);

                    securityUserDto.Password     = securityUser.Password;
                    securityUserDto.PasswordSalt = securityUser.PasswordSalt;

                    _SecurityUserMapper.MapToSecurityUser(securityUser, securityUserDto);

                    unitOfWork.SecurityUserRepository.Update(securityUser);
                    unitOfWork.Save();

                    updatedSecurityUserDto = _SecurityUserMapper.MapToSecurityUserDto(unitOfWork.SecurityUserRepository.GetByID(p => p.SecurityUserId == securityUserDto.SecurityUserId));
                }

                scope.Complete();
            }

            return(updatedSecurityUserDto);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Gets the user from the specified security user.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <returns></returns>
        public UserDto GetUser(SecurityUserDto user)
        {
            var entity = (from u in this.Session.Query <User>()
                          where u.Id == user.Id
                          select u).Single();

            return(Mapper.Map <User, UserDto>(entity));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Updates the specified user.
        /// </summary>
        /// <param name="user">The user.</param>
        public void Update(SecurityUserDto user)
        {
            Assert.IsNotNull(user, "user");

            var entity = this.Session.Get <User>(user.Id);

            Mapper.Map <SecurityUserDto, User>(user, entity);

            this.Session.Merge(entity);
        }
Ejemplo n.º 9
0
        public UserDto LoadUser(SecurityUserDto user)
        {
            var fullUser = this.Session.Get <User>(user.Id);

            if (fullUser == null)
            {
                return(null);
            }
            var result = Mapper.Map <User, UserDto>(fullUser);

            return(result);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Determines whether this specified usr is super admin.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <returns>
        ///   <c>true</c> if the specified useris super admin; otherwise, <c>false</c>.
        /// </returns>
        public bool IsSuperAdmin(SecurityUserDto user)
        {
            var superadmin = (from u in this.Session.Query <User>()
                              where u.Id == user.Id
                              select u).FirstOrDefault();

            if (superadmin == null)
            {
                throw new BusinessLogicException("The database is in a wrong state: there is no super admin.", Messages.Ex_NoSuperAdmin);
            }
            return(superadmin.IsSuperAdmin);
        }
Ejemplo n.º 11
0
        public void UpdateEmptyUser()
        {
            SecurityUserDto securityUserDto = new SecurityUserDto()
            {
                CrudOperation = CrudOperations.Update
            };
            Response <SecurityUserDto> response = _PhekoServiceClient.SaveUser(securityUserDto);

            Assert.IsTrue(response.HasErrors);
            Assert.IsTrue(response.FieldErrors.Count > 0);
            Assert.IsNull(response.Model);
        }
Ejemplo n.º 12
0
 private void RefreshDataContext(SecurityUserDto user)
 {
     this.Dispatcher.Invoke((Action) delegate
     {
         if (this.DataContext != null && this.DataContext is MainWindowViewModel)
         {
             (this.DataContext as MainWindowViewModel).ConnectedUser = user;
         }
         else
         {
             throw new WrongDataContextException();
         }
     });
     this.OnNewUserConnected();
 }
Ejemplo n.º 13
0
        public void InvalidCreateUserTest()
        {
            SecurityUserDto securityUser = new SecurityUserDto()
            {
                Title         = "Mr",
                IDNumber      = "8707255584080",
                CrudOperation = CrudOperations.Create
            };

            Response <SecurityUserDto> response = _PhekoServiceClient.SaveUser(securityUser);

            Assert.IsTrue(response.HasErrors);
            Assert.IsTrue(response.FieldErrors.Count > 0);
            Assert.IsNull(response.Model);
        }
Ejemplo n.º 14
0
        public void MapToSecurityUser(SecurityUser securityUser, SecurityUserDto securityUserDto)
        {
            if (securityUserDto == null)
            {
                return;
            }

            securityUser = securityUser ?? new SecurityUser();

            SecurityUserRoleMapper securityUserRoleMapper = new SecurityUserRoleMapper();

            securityUser.UserName            = securityUserDto.UserName;
            securityUser.Title               = securityUserDto.Title;
            securityUser.FirstName           = securityUserDto.FirstName;
            securityUser.LastName            = securityUserDto.LastName;
            securityUser.Initials            = securityUserDto.Initials;
            securityUser.IDNumber            = securityUserDto.IDNumber;
            securityUser.BirthDate           = securityUserDto.BirthDate;
            securityUser.Gender              = securityUserDto.Gender;
            securityUser.WorkTelephoneCode   = securityUserDto.WorkTelephoneCode;
            securityUser.WorkTelephoneNumber = securityUserDto.WorkTelephoneNumber;
            securityUser.FaxCode             = securityUserDto.FaxCode;
            securityUser.FaxNumber           = securityUserDto.FaxNumber;
            securityUser.MobileNumber        = securityUserDto.MobileNumber;
            securityUser.EmailAddress        = securityUserDto.EmailAddress;
            securityUser.EmployeeNumber      = securityUserDto.EmployeeNumber;
            securityUser.DisabledDate        = securityUserDto.DisabledDate;
            securityUser.PasswordSalt        = securityUserDto.PasswordSalt;
            securityUser.Password            = securityUserDto.Password;
            securityUser.FirstTimeLogInInd   = securityUserDto.FirstTimeLogInInd;

            if (securityUserDto.SecurityUserRoles != null && securityUserDto.SecurityUserRoles.Count > 0)
            {
                foreach (SecurityUserRoleDto securityUserRoleDto in securityUserDto.SecurityUserRoles)
                {
                    SecurityUserRole securityUserRole = securityUserRoleDto.SecurityUserRoleId == null ? null : securityUser.SecurityUserRoles.Where(item => item.SecurityUserRoleId == securityUserRoleDto.SecurityUserRoleId).FirstOrDefault <SecurityUserRole>();

                    if (securityUserRole == null)
                    {
                        securityUserRole = new SecurityUserRole();
                    }

                    securityUserRoleMapper.MapToSecurityUserRole(securityUserRole, securityUserRoleDto);

                    securityUser.SecurityUserRoles.Add(securityUserRole);
                }
            }
        }
Ejemplo n.º 15
0
        public void UpdateNonExistingUser()
        {
            SecurityUserDto securityUserDto = new SecurityUserDto()
            {
                SecurityUserId = -4,
                Title          = "Mr",
                IDNumber       = "8707255584080",
                CrudOperation  = CrudOperations.Update
            };

            Response <SecurityUserDto> response = _PhekoServiceClient.SaveUser(securityUserDto);

            Assert.IsTrue(response.HasErrors);
            Assert.IsTrue(response.FieldErrors.Count > 0);
            Assert.IsNull(response.Model);
        }
Ejemplo n.º 16
0
        public void CreateUser_CreateUsersWithSameFirstAndLastName_ExceptionIsExpected()
        {
            var firstName = "Robert";
            var lastName  = "Dupont";

            var user1 = new SecurityUserDto()
            {
                FirstName = firstName, LastName = lastName
            };
            var user2 = new SecurityUserDto()
            {
                FirstName = firstName, LastName = lastName
            };

            this.ComponentUnderTest.Create(user1, "a");
            Assert.Throws <ExistingItemException>(() => this.ComponentUnderTest.Create(user2, "az"));
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Updates the password of the connected user.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="password">The password.</param>
        public void Update(SecurityUserDto user, string password)
        {
            if (string.IsNullOrWhiteSpace(password))
            {
                throw new EmptyPasswordException();
            }

            var entity = this.Session.Get <User>(user.Id);

            if (entity == null)
            {
                throw new EntityNotFoundException(typeof(User));
            }

            entity.Password = password;
            this.Session.Update(entity);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Removes the specified user from the repository.
        /// </summary>
        /// <param name="user">The user.</param>
        public void Remove(SecurityUserDto user)
        {
            var aptEntities = (from a in this.Session.Query <Appointment>()
                               where a.User.Id == user.Id
                               select a);

            foreach (var item in aptEntities)
            {
                this.Session.Delete(item);
            }

            var userEntities = (from u in this.Session.Query <User>()
                                where u.Id == user.Id
                                select u);

            foreach (var item in userEntities)
            {
                this.Session.Delete(item);
            }
        }
Ejemplo n.º 19
0
        private SecurityUserDto Create(SecurityUserDto securityUserDto)
        {
            SecurityUserDto addedSecurityUserDto = null;
            SecurityUser    securityUser         = new SecurityUser();

            using (TransactionScope scope = new TransactionScope())
            {
                _SecurityUserMapper.MapToSecurityUser(securityUser, securityUserDto);

                using (UnitOfWork unitOfWork = new UnitOfWork())
                {
                    unitOfWork.SecurityUserRepository.Insert(securityUser);
                    unitOfWork.Save();

                    addedSecurityUserDto = _SecurityUserMapper.MapToSecurityUserDto(securityUser);
                }
            }

            return(addedSecurityUserDto);
        }
Ejemplo n.º 20
0
        public SecurityUserDto MapToSecurityUserDto(SecurityUser securityUser)
        {
            if (securityUser == null)
            {
                return(null);
            }

            SecurityUserDto securityUserDto = new SecurityUserDto();

            SecurityUserRoleMapper securityUserRoleMapper = new SecurityUserRoleMapper();

            securityUserDto.SecurityUserId      = securityUser.SecurityUserId;
            securityUserDto.UserName            = securityUser.UserName;
            securityUserDto.Title               = securityUser.Title;
            securityUserDto.FirstName           = securityUser.FirstName;
            securityUserDto.LastName            = securityUser.LastName;
            securityUserDto.Initials            = securityUser.Initials;
            securityUserDto.IDNumber            = securityUser.IDNumber;
            securityUserDto.BirthDate           = securityUser.BirthDate;
            securityUserDto.Gender              = securityUser.Gender;
            securityUserDto.WorkTelephoneCode   = securityUser.WorkTelephoneCode;
            securityUserDto.WorkTelephoneNumber = securityUser.WorkTelephoneNumber;
            securityUserDto.FaxCode             = securityUser.FaxCode;
            securityUserDto.FaxNumber           = securityUser.FaxNumber;
            securityUserDto.MobileNumber        = securityUser.MobileNumber;
            securityUserDto.EmailAddress        = securityUser.EmailAddress;
            securityUserDto.EmployeeNumber      = securityUser.EmployeeNumber;
            securityUserDto.DisabledDate        = securityUser.DisabledDate;
            securityUserDto.PasswordSalt        = securityUser.PasswordSalt;
            securityUserDto.Password            = securityUser.Password;
            securityUserDto.FirstTimeLogInInd   = securityUser.FirstTimeLogInInd;

            if (securityUser.SecurityUserRoles != null && securityUser.SecurityUserRoles.Count > 0)
            {
                securityUserDto.SecurityUserRoles = new List <SecurityUserRoleDto>();
                securityUser.SecurityUserRoles.ToList <SecurityUserRole>().ForEach(item => securityUserDto.SecurityUserRoles.Add(securityUserRoleMapper.MapToSecurityUserRoleDto(item)));
            }

            return(securityUserDto);
        }
Ejemplo n.º 21
0
        public void ValidCreateUserTest()
        {
            SecurityUserDto securityUser = new SecurityUserDto()
            {
                Title         = "Mr",
                FirstName     = "Qinisela",
                LastName      = "Molefe",
                Initials      = "Q E",
                UserName      = GeneratePassword.CreateRandomPassword(),
                PasswordSalt  = GeneratePassword.PasswordSalt(),
                IDNumber      = "8707255584080",
                CrudOperation = CrudOperations.Create
            };

            securityUser.Password = GeneratePassword.HashedPassword("password1", securityUser.PasswordSalt);

            Response <SecurityUserDto> response = _PhekoServiceClient.SaveUser(securityUser);

            Assert.IsFalse(response.HasErrors);
            Assert.IsTrue(response.FieldErrors.Count == 0);
            Assert.IsNotNull(response.Model);
        }
Ejemplo n.º 22
0
        public bool CanConnect(SecurityUserDto user, string password)
        {
            if (user == null || password == null)
            {
                return(false);
            }

            if (!Session.IsOpen)
            {
                throw new SessionNotOpenedException();
            }
            var foundUser = Session.Get <User>(user.Id);

            if (user == null)
            {
                return(false);
            }

            var userPwd = foundUser.Password ?? string.Empty;

            return(password == userPwd);
        }
Ejemplo n.º 23
0
        public void UpdateExistingUser()
        {
            SecurityUserDto securityUser = new SecurityUserDto()
            {
                SecurityUserId      = 6,
                Title               = "Mr",
                FirstName           = "Qinisela Elvis",
                LastName            = "Molefe",
                Initials            = "Q E",
                IDNumber            = "8707255584080",
                UserName            = "******",
                Gender              = "Male",
                WorkTelephoneCode   = "011",
                WorkTelephoneNumber = "4470987",
                CrudOperation       = CrudOperations.Update
            };

            Response <SecurityUserDto> response = _PhekoServiceClient.SaveUser(securityUser);

            Assert.IsFalse(response.HasErrors);
            Assert.IsTrue(response.FieldErrors.Count == 0);
            Assert.IsNotNull(response.Model);
        }
        public SecurityUserDto MapToSecurityUserDto(SecurityUserViewModel securityUserViewModel)
        {
            if (securityUserViewModel == null)
            {
                return(null);
            }

            SecurityUserDto securityUserDto = new SecurityUserDto();

            securityUserDto.SecurityUserId      = securityUserViewModel.SecurityUserId;
            securityUserDto.UserName            = securityUserViewModel.UserName;
            securityUserDto.Title               = securityUserViewModel.Title;
            securityUserDto.Initials            = securityUserViewModel.Initials;
            securityUserDto.FirstName           = securityUserViewModel.FirstName;
            securityUserDto.LastName            = securityUserViewModel.LastName;
            securityUserDto.IDNumber            = securityUserViewModel.IDNumber;
            securityUserDto.BirthDate           = securityUserViewModel.BirthDate;
            securityUserDto.Gender              = securityUserViewModel.Gender;
            securityUserDto.WorkTelephoneCode   = securityUserViewModel.WorkTelephoneCode;
            securityUserDto.WorkTelephoneNumber = securityUserViewModel.WorkTelephoneNumber;
            securityUserDto.FaxCode             = securityUserViewModel.FaxCode;
            securityUserDto.FaxNumber           = securityUserViewModel.FaxNumber;
            securityUserDto.MobileNumber        = securityUserViewModel.MobileNumber;
            securityUserDto.EmailAddress        = securityUserViewModel.EmailAddress;
            securityUserDto.EmployeeNumber      = securityUserViewModel.EmployeeNumber;
            securityUserDto.DisabledDate        = securityUserViewModel.DisabledDate;

            securityUserDto.SecurityUserRoles = new List <SecurityUserRoleDto>
            {
                { new SecurityUserRoleDto {
                      SecurityRoleId = securityUserViewModel.SecurityUserRoleId.Value
                  } }
            };

            return(securityUserDto);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Creates the specified user.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="password">The password.</param>
        public long Create(SecurityUserDto item, string password)
        {
            Assert.IsNotNull(item, "item");
            if (string.IsNullOrEmpty(password))
            {
                throw new EmptyPasswordException();
            }

            var found = (from p in this.Session.Query <User>()
                         where p.Id == item.Id ||
                         (p.FirstName == item.FirstName &&
                          p.LastName == item.LastName)

                         select p).ToList().Count() > 0;

            if (found)
            {
                throw new ExistingItemException();
            }

            var entity = Mapper.Map <SecurityUserDto, User>(item);

            entity.Password = password;

            if (entity.IsDefault)
            {
                this.RemoveDefaultUser();
            }
            if (this.IsFirstUser())
            {
                entity.IsSuperAdmin = true;
            }

            item.Id = (long)this.Session.Save(entity);
            return(item.Id);
        }
Ejemplo n.º 26
0
 /// <summary>
 /// Updates the specified user.
 /// </summary>
 /// <param name="user">The user.</param>
 public void Update(SecurityUserDto user)
 {
     new Updator(this.Session).Update(user);
 }
Ejemplo n.º 27
0
 public DoorKeeper(SecurityUserDto user)
 {
     this.user = user;
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Connects the specified user into the application.
 /// </summary>
 /// <param name="user">The user.</param>
 public void ConnectUser(SecurityUserDto user)
 {
     AuthorisationInterceptor.User = user;
 }
Ejemplo n.º 29
0
        public Response <SecurityUserDto> UpdateUserCheck(SecurityUserDto securityUserDto)
        {
            Response <SecurityUserDto> response = new Response <SecurityUserDto>();

            if (securityUserDto == null ||
                securityUserDto.SecurityUserId == null ||
                securityUserDto.SecurityUserId.Value == int.MinValue)
            {
                response.HasErrors = true;
                response.FieldErrors.Add(new FieldError()
                {
                    ErrorMessage = "The entry you trying to update does not exist."
                });
                return(response);
            }

            using (UnitOfWork unitOfWork = new UnitOfWork())
            {
                SecurityUser securityUser = unitOfWork.SecurityUserRepository.GetByID(s => s.SecurityUserId == securityUserDto.SecurityUserId.Value);

                if (securityUser == null)
                {
                    response.HasErrors = true;
                    response.FieldErrors.Add(new FieldError()
                    {
                        ErrorMessage = "The entry you trying to update does not exist."
                    });
                    return(response);
                }
            }

            if (string.IsNullOrEmpty(securityUserDto.UserName))
            {
                response.HasErrors = true;
                response.FieldErrors.Add(new FieldError()
                {
                    FieldName = "Username", ErrorMessage = "Username is required."
                });
            }
            else
            {
                using (UnitOfWork unitOfWork = new UnitOfWork())
                {
                    SecurityUser securityUser = unitOfWork.SecurityUserRepository.GetEntities(s => s.SecurityUserId != securityUserDto.SecurityUserId.Value &&
                                                                                              s.UserName.ToLower() == securityUserDto.UserName.ToLower())
                                                .FirstOrDefault <SecurityUser>();

                    if (securityUser != null)
                    {
                        response.HasErrors = true;
                        response.FieldErrors.Add(new FieldError()
                        {
                            FieldName = "Username", ErrorMessage = "Username is currently being used another user."
                        });
                    }
                }
            }

            if (string.IsNullOrEmpty(securityUserDto.FirstName))
            {
                response.HasErrors = true;
                response.FieldErrors.Add(new FieldError()
                {
                    FieldName = "FirstName", ErrorMessage = "FirstName is required."
                });
            }

            if (string.IsNullOrEmpty(securityUserDto.LastName))
            {
                response.HasErrors = true;
                response.FieldErrors.Add(new FieldError()
                {
                    FieldName = "LastName", ErrorMessage = "LastName is required."
                });
            }

            if (string.IsNullOrEmpty(securityUserDto.Initials))
            {
                response.HasErrors = true;
                response.FieldErrors.Add(new FieldError()
                {
                    FieldName = "Initials", ErrorMessage = "Initials is required."
                });
            }

            return(response);
        }
Ejemplo n.º 30
0
 public Response <SecurityUserDto> SaveUser(SecurityUserDto securityUser)
 {
     return(_ISecurityUserManager.SaveUser(securityUser));
 }