public IActionResult CreateTender(TenderDTO tender) { Tender newTender = _tenderService.CreateTender(tender); int medicationCount = 0; foreach (TenderMedicationDTO medicationDTO in tender.tenderMedications) { TenderMedication tenderMedication = _tenderService.CreateMedicationForTender(newTender.Id, medicationDTO); if (tenderMedication != null) { medicationCount++; } } bool isTenderSuccessfullyAdded = newTender != null; bool isMedicationSuccessfullyAdded = medicationCount == tender.tenderMedications.Count(); if (isTenderSuccessfullyAdded && isMedicationSuccessfullyAdded) { //SendMail(); return(Ok()); } else { return(BadRequest()); } }
public TenderMedication CreateMedicationForTender(int tenderId, TenderMedicationDTO medicationDTO) { TenderMedication tenderMedication = new TenderMedication(medicationDTO, tenderId); return(_tenderMedicationRepository.Create(tenderMedication)); }