public async Task <int> ApplyUserForOffer(UserAppliesForOfferDTO uafoDTO) { var offer = await offerRepository.GetAsync(uafoDTO.Offer.Id); Mapper.Map(uafoDTO, offer); offer.ApplierId = uafoDTO.ApplierId; offer.ApplierRole = uafoDTO.ApplierRole.ToString(); offerRepository.Update(offer); return(offer.Id); }
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); } }