Exemple #1
0
        public string Validate(TenderDTO tender)
        {
            if (null == tender)
            {
                return(GenericMessages.ObjectIsNull);
            }

            if (tender.TenderNumber == null)
            {
                return("Tender Number " + GenericMessages.ObjectIsNull);
            }

            if (String.IsNullOrEmpty(tender.CompanyName))
            {
                return(tender.CompanyName + " " + GenericMessages.StringIsNullOrEmpty);
            }

            if (tender.CompanyName.Length > 255)
            {
                return(tender.CompanyName + " can not be more than 255 characters ");
            }


            return(string.Empty);
        }
Exemple #2
0
        public string InsertOrUpdate(TenderDTO tender)
        {
            try
            {
                var validate = Validate(tender);
                if (!string.IsNullOrEmpty(validate))
                {
                    return(validate);
                }

                if (ObjectExists(tender))
                {
                    return(GenericMessages.DatabaseErrorRecordAlreadyExists + Environment.NewLine +
                           "With the same Number");
                }

                _tenderRepository.InsertUpdate(tender);
                _unitOfWork.Commit();
                return(string.Empty);
            }
            catch (Exception exception)
            {
                return(exception.Message);
            }
        }
Exemple #3
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());
            }
        }
Exemple #4
0
        public bool ObjectExists(TenderDTO tender)
        {
            var objectExists = false;
            var iDbContext   = DbContextUtil.GetDbContextInstance();

            try
            {
                var catRepository = new Repository <TenderDTO>(iDbContext);
                var catExists     = catRepository.Query()
                                    .Filter(bp => bp.TenderNumber == tender.TenderNumber && bp.Id != tender.Id)
                                    .Get()
                                    .FirstOrDefault();

                if (catExists != null)
                {
                    objectExists = true;
                }
            }
            finally
            {
                iDbContext.Dispose();
            }

            return(objectExists);
        }
Exemple #5
0
        public Guid Create(TenderDTO entityDTO)
        {
            Tender tender = CreateTenderFromDTO(entityDTO);

            _tenderRepository.Create(tender);

            return(tender.Id);
        }
        public async Task <ActionResult> EditTender(Guid tenderGuid)
        {
            TenderDTO tender = await TenderProvider.GetTender(tenderGuid);

            var viewModel = new TenderAboveThresholdUAViewModel(tender);

            return(View(viewModel));
        }
Exemple #7
0
 public Tender(TenderDTO tenderDTO)
 {
     StartDate         = DateTime.Now;
     EndDate           = tenderDTO.EndDate;
     TenderStatus      = TenderStatus.Active;
     TenderMedications = new List <TenderMedication>();
     TenderDescription = tenderDTO.TenderDescription;
 }
        public async Task <ActionResult> EditTender(Guid tenderGuid)
        {
            TenderDTO tender = await TenderProvider.GetTender(tenderGuid);

            var viewModel = new TenderLimitedQuickViewModel(tender);

            return(View(viewModel));
        }
 private void AddNewTender()
 {
     SelectedTender = new TenderDTO
     {
         //Type = TenderType,
         //TenderDate = DateTime.Now,
         //Method = TenderMethods.Cash,
         //Status = TenderStatus.NotCleared
     };
 }
 public IActionResult Add([FromBody] TenderDTO dto)
 {
     try
     {
         _tenderService.Create(dto);
         return(Ok(dto));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
        private TenderDTO CreateTenderDTO()
        {
            List <TenderMedicationDTO> medications = new List <TenderMedicationDTO>();

            medications.Add(new TenderMedicationDTO(5, "Brufen", "200mg", 100));
            TenderDTO tender = new TenderDTO
            {
                EndDate           = new DateTime(2021, 6, 1),
                tenderMedications = medications,
                TenderDescription = "Tender for brufen",
            };

            return(tender);
        }
Exemple #12
0
        public async Task EditTender(TenderDTO tenderDTO)
        {
            if (!AccessManager.CanCreateTender)
            {
                throw new AccessViolationException();
            }
            string acc_token = await AccessManager.GetTenderTokenAsync(tenderDTO.Guid);

            using (var service = new TendersService())
            {
                var changes = await service.ChangeTender(tenderDTO.Guid, tenderDTO.DropComplexProperties(), acc_token);

                //await Context.TryUpdateTender(changes);
            }
        }
Exemple #13
0
        public string Disable(TenderDTO tender)
        {
            if (tender == null)
            {
                return(GenericMessages.ObjectIsNull);
            }

            string stat;

            try
            {
                _tenderRepository.Update(tender);
                _unitOfWork.Commit();
                stat = string.Empty;
            }
            catch (Exception exception)
            {
                stat = exception.Message;
            }
            return(stat);
        }
Exemple #14
0
        public Tender CreateTender(TenderDTO tenderDTO)
        {
            Tender tender = new Tender(tenderDTO);

            return(_tenderRepository.Create(tender));
        }
Exemple #15
0
 public TenderEntry(TenderDTO tenderDTO)
 {
     TenderEntryViewModel.Errors = 0;
     InitializeComponent();
     Messenger.Default.Send <TenderDTO>(tenderDTO);
 }
Exemple #16
0
 public void Update(TenderDTO entityDTO, Guid id)
 {
     _tenderRepository.Update(CreateTenderFromDTO(entityDTO));
 }
Exemple #17
0
 private Tender CreateTenderFromDTO(TenderDTO tender, Guid?id = null)
 => id == null ? new Tender(tender.Name, tender.Descritpion, tender.FormLink,
                            tender.StartDate, tender.EndDate)
                 : new Tender(id.Value, tender.Name, tender.Descritpion, tender.FormLink,
                              tender.StartDate, tender.EndDate);