コード例 #1
0
        /// <summary>
        /// Initializes an instance of the <see cref="UserDetailsViewModel"/> class
        /// </summary>
        public UserDetailsViewModel(UserFullDetailsDto userFullDetails)
        {
            if (userFullDetails == null)
            {
                throw new ArgumentNullException(nameof(userFullDetails));
            }

            UserId         = userFullDetails.UserId;
            Username       = userFullDetails.Username;
            JobDescription = userFullDetails.JobDescription ?? throw new ArgumentNullException(nameof(userFullDetails.JobDescription));
            Role           = userFullDetails.Role;
            State          = userFullDetails.State;
            EmployeeId     = userFullDetails.EmployeeId;
            Title          = userFullDetails.Title;
            Firstname      = userFullDetails.Firstname;
            Lastname       = userFullDetails.Lastname;

            // Gets the list of Roles for the drop down
            TitlesSelectListItems = SelectListHelpers.GetTitlesSelectList(Title);

            // Gets the list of Roles for the drop down
            RolesSelectListItems = SelectListHelpers.GetRolesSelectList(Role);

            // Gets the list of Account States for the drop down
            AccountStatesSelectListItems = SelectListHelpers.GetAccountStatesSelectList(State);
        }
コード例 #2
0
 private void UpdateUserProperties(ref User user, UserFullDetailsDto updatedDetails)
 {
     user.State = updatedDetails.State;
     user.JobDescription.Description = updatedDetails.JobDescription;
     user.JobDescription.Role        = updatedDetails.Role;
     user.EmployeeDetails.Firstname  = updatedDetails.Firstname;
     user.EmployeeDetails.Lastname   = updatedDetails.Lastname;
 }
コード例 #3
0
ファイル: User.cs プロジェクト: Echoes675/MediBook
        /// <summary>
        /// Initializes an instance of the <see cref="UserFullDetailsDto"/> class
        /// </summary>
        public User(UserFullDetailsDto dto)
        {
            if (dto == null)
            {
                throw new ArgumentNullException(nameof(dto));
            }

            Id       = dto.UserId;
            Username = dto.Username;
            JobDescription.Description = dto.JobDescription;
            JobDescription.Role        = dto.Role;
            State = dto.State;
            EmployeeDetails.Id        = dto.EmployeeId;
            EmployeeDetails.Title     = dto.Title;
            EmployeeDetails.Firstname = dto.Firstname;
            EmployeeDetails.Lastname  = dto.Lastname;
        }
コード例 #4
0
        /// <summary>
        /// Saves the updated user details
        /// </summary>
        /// <param name="userDetails"></param>
        /// <returns></returns>
        public async Task <ServiceResultStatusCode> UpdateUserDetailsAsync(UserFullDetailsDto userDetails)
        {
            if (userDetails == null)
            {
                throw new ArgumentNullException(nameof(userDetails));
            }

            var dbUser = await _userDal.GetEntityAsync(userDetails.UserId);

            if (dbUser == null)
            {
                return(ServiceResultStatusCode.NotFound);
            }

            UpdateUserProperties(ref dbUser, userDetails);

            return(await _userDal.UpdateAsync(dbUser) != null ? ServiceResultStatusCode.Success : ServiceResultStatusCode.Failed);
        }