public CompanyType Map(EditCompanyTypeRequest request) { if (request == null) { return(null); } CompanyType companyType = new CompanyType { Id = request.Id, Name = request.Name, Type = request.Type, }; return(companyType); }
public async Task <CompanyTypeResponse> EditCompanyTypeAsync(EditCompanyTypeRequest request) { CompanyType existingRecord = await _companyTypeRespository.GetAsync(request.Id); if (existingRecord == null) { throw new ArgumentException($"Entity with {request.Id} is not present"); } CompanyType entity = _companyTypeMapper.Map(request); CompanyType result = _companyTypeRespository.Update(entity); int modifiedRecords = await _companyTypeRespository.UnitOfWork.SaveChangesAsync(); _logger.LogInformation(Logging.Events.Edit, Messages.NumberOfRecordAffected_modifiedRecords, modifiedRecords); _logger.LogInformation(Logging.Events.Edit, Messages.ChangesApplied_id, result?.Id); return(_companyTypeMapper.Map(result)); }
public async Task <IActionResult> Put(Guid id, EditCompanyTypeRequest request) { request.Id = id; return(Ok(await _mediator.Send(new EditCompanyTypeCommand(request)))); }