public async Task <MechanicConfirmation> UpdateMechanicAsync(Guid updateMechanicId, MechanicPutBody putMechanicBody) { var mechanicToUpdate = await _context.Set <Mechanic>() .FirstOrDefaultAsync(e => e.Id == updateMechanicId); if (mechanicToUpdate == null) { return(null); } mechanicToUpdate.Name = putMechanicBody.Name; mechanicToUpdate.LastName = putMechanicBody.LastName; mechanicToUpdate.Contact = putMechanicBody.Contact; mechanicToUpdate.Email = putMechanicBody.Email; mechanicToUpdate.JMBG = putMechanicBody.JMBG; mechanicToUpdate.City = putMechanicBody.City; mechanicToUpdate.Address = putMechanicBody.Address; mechanicToUpdate.Specialization = putMechanicBody.Specialization; mechanicToUpdate.Password = putMechanicBody.Password; await _context.SaveChangesAsync(); _logger.LogInformation("UpdateMechanicAsync() Executed!"); return(await Task.FromResult(_mapper.Map <MechanicConfirmation>(mechanicToUpdate))); }
public async Task <ActionResult <MechanicConfirmation> > PutMechanic(Guid updateMechanicId, [FromBody] MechanicPutBody putMechanicBody) { var updatedMechanicConfirmation = await _service.UpdateMechanicAsync(updateMechanicId, putMechanicBody); if (updatedMechanicConfirmation == null) { return(BadRequest()); } return(Ok(updatedMechanicConfirmation)); }