Explorar el Código

UpdateProfile

zinab_elgendy hace 6 meses
padre
commit
e098ea7302

+ 3 - 3
MTWorkHR.API/Controllers/CompanyController.cs

@@ -43,10 +43,10 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Update")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
-        public async Task Update([FromBody] CompanyDto input)
+        [Consumes("multipart/form-data")]
+        public async Task<ActionResult<CompanyDto>> Update([FromForm] CompanyDto input)
         {
-            await _companyService.Update(input);
+            return await _companyService.Update(input);
         }
 
         [HttpPost("Delete")]

+ 1 - 0
MTWorkHR.Application/Mapper/MappingProfile.cs

@@ -108,6 +108,7 @@ namespace MTWorkHR.Application.Mapper
             CreateMap<City, CityDto>().ReverseMap();
             CreateMap<UserDto, CompanyUserDto>();
             CreateMap<CompanyUserDto, UserDto>().ForMember(m => m.UserName, o => o.MapFrom(s => s.Email)).ReverseMap();
+            CreateMap<CompanyUserDto, UserUpdateDto>().ReverseMap();
 
 
             CreateMap<CompanyUserDto, ApplicationUser>()

+ 4 - 3
MTWorkHR.Application/Services/User/CompanyService.cs

@@ -163,10 +163,11 @@ namespace MTWorkHR.Application.Services
 
         public override async Task<CompanyDto> Update(CompanyDto input)
         {
-            var companyUser = MapperObject.Mapper.Map<UserUpdateDto>(input.CompanyUser);
+            //var companyUser = MapperObject.Mapper.Map<UserUpdateDto>(input.CompanyUser);
             _unitOfWork.BeginTran();
 
-            await UpdateCompanyUser(input);
+            var returnedUser = await UpdateCompanyUser(input);
+            //var entity = await GetById(input.Id);
             var entity = await _unitOfWork.Company.GetByIdAsync(input.Id);
 
             if (entity == null)
@@ -249,7 +250,7 @@ namespace MTWorkHR.Application.Services
             {
                 throw e;
             }
-            var userResponse = await GetById(input.Id);
+            var userResponse = await _userService.GetById(input.CompanyUser.Id);
             var user = MapperObject.Mapper.Map<UserUpdateDto>(userResponse);
             return user;
         }