コード例 #1
0
        // [DUTAuthorize]
        public IHttpActionResult UpdateEmployeeProfile([FromBody] UpdateEmployeeProfile updateEmployeeProfile)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                _employeeProfileService.UpdateEmployeeProfile(updateEmployeeProfile, Request.GetAuthorizationHeader());
                return(Ok());
            }
            catch (System.Exception e)
            {
                return(InternalServerError(e));
            }
        }
コード例 #2
0
        public void UpdateEmployeeProfile(UpdateEmployeeProfile updateEmployeeProfile, string token)
        {
            int id       = JwtAuthenticationExtensions.ExtractTokenInformation(token).UserId;
            var userInfo = context.UserInfoes.FirstOrDefault(x => !x.DelFlag && x.Id == id);

            if (userInfo != null)
            {
                userInfo.FirstName                   = updateEmployeeProfile.FirstName;
                userInfo.LastName                    = updateEmployeeProfile.LastName;
                userInfo.Avatar                      = updateEmployeeProfile.Avatar;
                userInfo.BirthInfo.DateOfBirth       = updateEmployeeProfile.DateOfBirth;
                userInfo.BirthInfo.PlaceOfBirth      = updateEmployeeProfile.PlaceOfBirth;
                userInfo.BirthInfo.Sex               = updateEmployeeProfile.Sex;
                userInfo.ContactInfo.PhoneNumber     = updateEmployeeProfile.PhoneNumber;
                userInfo.ContactInfo.Email           = updateEmployeeProfile.Email;
                userInfo.ContactInfo.Address         = updateEmployeeProfile.Address;
                userInfo.IdentityInfo.IdentityNumber = updateEmployeeProfile.IdentityNumber;
            }
            context.SaveChanges();
        }