예제 #1
0
        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());
            }
        }
예제 #2
0
        public TenderMedication CreateMedicationForTender(int tenderId, TenderMedicationDTO medicationDTO)
        {
            TenderMedication tenderMedication = new TenderMedication(medicationDTO, tenderId);

            return(_tenderMedicationRepository.Create(tenderMedication));
        }