예제 #1
0
        public async Task <Guid> AddDraftTender(DraftTenderDTO draftTenderDTO)
        {
            var tender = draftTenderDTO.ToDraft();

            tender.ProcuringEntityId = AccessManager.UserOrganizationId;
            Context.DraftTenders.Add(tender);
            await Context.SaveChangesAsync();

            return(tender.Guid);
        }
예제 #2
0
 public static DraftTender ToDraft(this DraftTenderDTO source)
 {
     return(source == null
         ? null
         : new DraftTender(source)
     {
         Lots = source.Lots?.Select(x => x.ToDraft()).ToList(),
         Items = source.Items?.Select(x => x.ToDraft()).ToList(),
         Features = source.Features?.Select(x => x.ToDraft()).ToList(),
         Documents = source.Documents?.Select(x => x.ToDraft()).ToList()
     }.InitComplexProperties());
 }
예제 #3
0
        private async Task TenderValidation(DraftTenderDTO tender)
        {
            string type = tender.ProcurementMethodType;

            if (type == ProcurementMethodType.BELOW_THRESHOLD ||
                type == ProcurementMethodType.ABOVE_THRESHOLD_UA ||
                type == ProcurementMethodType.ABOVE_THRESHOLD_EU ||
                type == ProcurementMethodType.ABOVE_THRESHOLD_UA_DEFENSE)
            {
                if (tender.Lots.Count == 0)
                {
                    ModelState.AddModelError("", "Потрібно додати хоча б один лот.");
                }
            }

            var items = new List <ItemDTO>();

            foreach (var lot in tender.Lots)
            {
                items.AddRange(lot.Items);
            }
            items.AddRange(tender.Items);
            if (items.Count == 0)
            {
                ModelState.AddModelError("", "Потрібно додати хоча б одну закупівлю.");
            }

            if (type == ProcurementMethodType.ABOVE_THRESHOLD_EU ||
                type == ProcurementMethodType.ABOVE_THRESHOLD_UA_DEFENSE)
            {
                if (!tender.Contacts.Any())
                {
                    ModelState.AddModelError("", "Потрібно додати хоча б один контакт.");
                }
            }

            if (type == ProcurementMethodType.ABOVE_THRESHOLD_UA_DEFENSE)
            {
                int userId  = AccessManager.Value.UserOrganizationId;
                var account = await ProfileProvider.GetUserOrganization(userId);

                if (account.Kind != ProcuringEntityType.Defense)
                {
                    ModelState.AddModelError("", "Аккаунт повинен бути Defense типу.");
                }
            }
        }
예제 #4
0
        public async Task EditDraftTender(Guid tenderGuid, DraftTenderDTO draftTenderDTO)
        {
            var savedItem = await Context.DraftTenders
                            .Include(m => m.ProcuringEntity)
                            .Include(m => m.Lots)
                            .FirstOrDefaultAsync(m => m.Guid == draftTenderDTO.Guid);

            draftTenderDTO.ProcuringEntityId = savedItem.ProcuringEntityId;

            if (draftTenderDTO.ProcurementMethodType == ProcurementMethodType.ABOVE_THRESHOLD_UA_DEFENSE ||
                draftTenderDTO.ProcurementMethodType == ProcurementMethodType.ABOVE_THRESHOLD_EU ||
                draftTenderDTO.ProcurementMethodType == ProcurementMethodType.ABOVE_THRESHOLD_UA ||
                draftTenderDTO.ProcurementMethodType == ProcurementMethodType.BELOW_THRESHOLD
                )
            {
                draftTenderDTO.MinimalStep = savedItem.MinimalStep;
                draftTenderDTO.Guarantee   = savedItem.Guarantee;

                draftTenderDTO.MinimalStep.Currency    = draftTenderDTO.Value.Currency;
                draftTenderDTO.MinimalStep.VATIncluded = draftTenderDTO.Value.VATIncluded;
                draftTenderDTO.Guarantee.Currency      = draftTenderDTO.Value.Currency;
            }

            foreach (var lot in savedItem.Lots)
            {
                lot.Value.Currency    = draftTenderDTO.Value.Currency;
                lot.Value.VATIncluded = draftTenderDTO.Value.VATIncluded;

                lot.MinimalStep.Currency    = draftTenderDTO.Value.Currency;
                lot.MinimalStep.VATIncluded = draftTenderDTO.Value.VATIncluded;

                lot.Guarantee.Currency = draftTenderDTO.Value.Currency;
            }

            Context.Entry(savedItem).CurrentValues.SetValues(draftTenderDTO.InitComplexProperties());
            await Context.SaveChangesAsync();
        }