public async Task <MechanicConfirmation> CreateMechanicAsync(MechanicPostBody postMechanicBody) { Mechanic newMechanic = new() { Id = Guid.NewGuid(), Name = postMechanicBody.Name, LastName = postMechanicBody.LastName, Contact = postMechanicBody.Contact, Email = postMechanicBody.Email, JMBG = postMechanicBody.JMBG, City = postMechanicBody.City, Address = postMechanicBody.Address, Specialization = postMechanicBody.Specialization, Password = postMechanicBody.Password }; await _context.Set <Mechanic>() .AddAsync(newMechanic); await _context.SaveChangesAsync(); _logger.LogInformation("CreateMechanicAsync() Executed!"); return(await Task.FromResult(_mapper.Map <MechanicConfirmation>(newMechanic))); }
public async Task <ActionResult <MechanicConfirmation> > PostMechanic([FromBody] MechanicPostBody postMechanicBody) { var newMechanicConfirmation = await _service.CreateMechanicAsync(postMechanicBody); return(CreatedAtAction(nameof(GetMechanicById), new { mechanicId = newMechanicConfirmation.Id }, newMechanicConfirmation)); }