public async Task <IActionResult> NewMarketingLog([FromBody] SaveMarketingResource model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var marketing = new Marketing(model.Name, model.ContactNumber, model.ServiceInterested, model.SoftwareInterested, model.ConversionStatus, model.RateUs, model.SuggestionForYes, model.SuggestionForNo, model.Area, model.Date, model.Price, model.CurrentScenario, model.RateUsForNo, model.Fee, UserProfileId, AdminId, ServiceItems(model)); _marketingRepository.Add(marketing); await _unitOfWork.CompleteAsync(); return(Ok(_mapper.Map <Marketing, MarketingResource>(marketing))); }
public async Task <IActionResult> UpdateMarketingLog(int id, [FromBody] SaveMarketingResource model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var marketingFromDb = await _marketingRepository.GetAsync(id, UserProfileId); if (marketingFromDb == null) { return(NotFound()); } marketingFromDb.Modify(model.Name, model.ContactNumber, model.ServiceInterested, model.SoftwareInterested, model.ConversionStatus, model.RateUs, model.SuggestionForYes, model.SuggestionForNo, model.Area, model.Price, model.CurrentScenario, model.RateUsForNo, model.Fee, ServiceItems(model)); await _unitOfWork.CompleteAsync(); return(Ok(_mapper.Map <Marketing, MarketingResource>(marketingFromDb))); }
private static List <ServiceItem> ServiceItems(SaveMarketingResource model) { return(model.ServiceItems.Select(item => ServiceItem.Add(item.ServiceType, item.Rate)) .ToList()); }