public Company Map(EditCompanyRequest request) { if (request == null) { return(null); } Company address = new Company { Id = request.Id, Name = request.Name, Addition = request.Addition, Addition2 = request.Addition2, Street = request.Street, PostCode = request.PostCode, City = request.City, Email = request.Email, Phone = request.Phone, Fax = request.Fax, VatId = request.VatId, TimeZone = request.TimeZone, ParentId = request.ParentId, CountryId = request.CountryId, LogoId = request.LogoId, CompanyTypeId = request.CompanyTypeId }; return(address); }
public object EditCompany(EditCompanyRequest req) { req.UpdatedBy = User.Identity.Name; var result = req.RunRequest(req); return(result); }
public async Task <CompanyResponse> EditCompanyAsync(EditCompanyRequest request) { Company existingRecord = await _companyRespository.GetAsync(request.Id); if (existingRecord == null) { throw new ArgumentException($"Entity with {request.Id} is not present"); } if (request.ParentId != null) { Company existingParent = await _companyRespository.GetAsync(request.ParentId); if (existingParent == null) { throw new NotFoundException($"Parent with {request.ParentId} is not present"); } } CompanyType existingCompanyType = await _companyTypeRespository.GetAsync(request.CompanyTypeId); if (existingCompanyType == null) { throw new NotFoundException($"CompanyType with {request.CompanyTypeId} is not present"); } Country existingCountry = await _countryRespository.GetAsync(request.CountryId); if (existingCountry == null) { throw new NotFoundException($"Country with {request.CountryId} is not present"); } if (request.LogoId != null) { FAGBinary existingFAGBinary = await _fagBinaryRespository.GetAsync(request.LogoId); if (existingFAGBinary == null) { throw new NotFoundException($"Logo with {request.LogoId} is not present"); } } Company entity = _companyMapper.Map(request); Company result = _companyRespository.Update(entity); int modifiedRecords = await _companyRespository.UnitOfWork.SaveChangesAsync(); _logger.LogInformation(Logging.Events.Edit, Messages.NumberOfRecordAffected_modifiedRecords, modifiedRecords); _logger.LogInformation(Logging.Events.Edit, Messages.ChangesApplied_id, result?.Id); return(_companyMapper.Map(result)); }
public async Task <IActionResult> Put(Guid id, EditCompanyRequest request) { request.Id = id; return(Ok(await _mediator.Send(new EditCompanyCommand(request)))); }