示例#1
0
        public void CloseTender(TenderDto tenderDto)
        {
            var tender = _databaseContext.Tenders.Find(tenderDto.TenderId);

            tender.isClosed = true;
            _databaseContext.SaveChanges();

            EvaluationTenderBids(tender.TenderId);
        }
示例#2
0
        public IActionResult CaptureNewTender([FromBody] TenderDto tenderDto)
        {
            if (tenderDto == null)
            {
                return(BadRequest("Invalid model"));
            }

            var result = _tenderService.AddNewTender(tenderDto);

            return(Ok(result));
        }
示例#3
0
        public void EditTender(TenderDto tenderBid)
        {
            var tender = _databaseContext.Tenders.Find(tenderBid.TenderId);

            tender.Description  = tenderBid.Description;
            tender.OpenDate     = tenderBid.OpenDate;
            tender.CloseDate    = tenderBid.CloseDate;
            tender.ContactNo    = tenderBid.ContactNo;
            tender.EmailAddress = tenderBid.EmailAddress;
            tender.StateOrganId = tenderBid.StateOrganId;

            _databaseContext.SaveChanges();
        }
示例#4
0
        public Tender AddNewTender(TenderDto tenderDto)
        {
            var tender = new Tender
            {
                Description  = tenderDto.Description,
                OpenDate     = tenderDto.OpenDate,
                CloseDate    = tenderDto.CloseDate,
                ContactNo    = tenderDto.ContactNo,
                EmailAddress = tenderDto.EmailAddress,
                StateOrganId = tenderDto.StateOrganId
            };

            _databaseContext.Tenders.Add(tender);
            _databaseContext.SaveChanges();

            return(tender);
        }
示例#5
0
        public async Task <TenderDto> GetTenderById(long tenderId)
        {
            var currentUser = await _userService.GetCurrentUserAsync();

            var tender = await GetFullQuery()
                         .SingleOrDefaultAsync(t => t.Id == tenderId);

            if (tender == null)
            {
                throw new NotFoundException("тендер с таким ID не найден");
            }

            var dto = new TenderDto();

            _mapper.Map(tender, dto, opt =>
                        opt.AfterMap((s, d) =>
            {
                d.Favorite = s.Favorites.Any(f => f.UserId == currentUser.Id);
            }));

            return(dto);
        }
示例#6
0
 public void Put([FromBody] TenderDto tenderDto)
 {
     _tenderService.CloseTender(tenderDto);
 }