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); }
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); } }
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 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); }
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)); }
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); }
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); } }
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); }
public Tender CreateTender(TenderDTO tenderDTO) { Tender tender = new Tender(tenderDTO); return(_tenderRepository.Create(tender)); }
public TenderEntry(TenderDTO tenderDTO) { TenderEntryViewModel.Errors = 0; InitializeComponent(); Messenger.Default.Send <TenderDTO>(tenderDTO); }
public void Update(TenderDTO entityDTO, Guid id) { _tenderRepository.Update(CreateTenderFromDTO(entityDTO)); }
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);