public async Task <int> ApplyUserForOffer(UserAppliesForOfferDTO userAppliesForOfferDTO) { using (var uow = UnitOfWorkProvider.Create()) { var offer = await offerService.GetAsync(userAppliesForOfferDTO.Offer.Id); if (userAppliesForOfferDTO.ApplierRole == UserRole.Corporation) { var corporation = await corporationService.GetAsync(userAppliesForOfferDTO.ApplierId); corporation.Offers.Add(userAppliesForOfferDTO.Offer); } else { var freelancer = await freelancerService.GetAsync(userAppliesForOfferDTO.ApplierId); freelancer.Offers.Add(userAppliesForOfferDTO.Offer); } return(offer.Id); } }