Example #1
0
        public IEnumerable <BidderDto> GetListBidder()
        {
            try
            {
                List <BidderDto> bidderDtos = new List <BidderDto>();
                List <Plis>      listPlis   = new List <Plis>();
                List <Bidder>    bidders    = new List <Bidder>();
                BidderDto        bidderDto;

                bidders = _context.Bidder.Include("address").Include("plis").Distinct().ToList();

                foreach (Bidder bidder in bidders)
                {
                    bidderDto = new BidderDto(bidder.Id, bidder.firstName, bidder.lastName, bidder.email, bidder.tel, bidder.fax, bidder.domaine, bidder.typeEnterprise, bidder.address);

                    bidderDtos.Add(bidderDto);
                }

                return(bidderDtos);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message + e.StackTrace);
                throw;
            }
        }
Example #2
0
        public BidderDto GetBidder(int biderId)
        {
            try
            {
                List <Bidder> bidders   = new List <Bidder>();
                BidderDto     bidderDto = new BidderDto();

                PlisDto plis;

                bidders = _context.Bidder.Include("address").Include("plis").ToList();

                foreach (Bidder bidder in bidders)
                {
                    if (bidder.Id == biderId)
                    {
                        bidderDto = new BidderDto(bidder.Id, bidder.firstName, bidder.lastName, bidder.email, bidder.tel, bidder.fax, bidder.domaine, bidder.typeEnterprise, bidder.address);
                        foreach (Plis pli in bidder.plis)
                        {
                            plis           = new PlisDto(pli.Id, pli.code, pli.libelle, pli.dateDepot, pli.typeDepot);
                            plis.offerId   = pli.offerId;
                            bidderDto.plis = new List <PlisDto>();
                            bidderDto.plis.Add(plis);
                        }
                    }
                }

                return(bidderDto);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message + e.StackTrace);
                throw;
            }
        }
Example #3
0
        public int PostBidder(BidderDto bidder)
        {
            try
            {
                Diffusion diffusion = new Diffusion();

                var offer     = _context.Offer.Include("diffusOffer").Where(o => o.id == bidder.offer.id).FirstOrDefault();
                var oldBidder = _context.Bidder.Where(b => b.email == bidder.email).FirstOrDefault();

                if (oldBidder != null)
                {
                    offer.diffusOffer.Add(new Diffusion(bidder.offer, oldBidder));
                }
                else
                {
                    Bidder newBidder = new Bidder(bidder.firstName, bidder.lastName, bidder.email, bidder.tel, bidder.fax, bidder.domaine, bidder.typeEnterprise, bidder.address);

                    offer.diffusOffer.Add(new Diffusion(bidder.offer, newBidder));
                }

                _context.SaveChanges();

                var bid = _context.Diffusion.Where(d => d.offerId == bidder.offer.id).FirstOrDefault().bidder;

                return(bid.Id);
            } catch (Exception e)
            {
                Debug.WriteLine(e.Message + e.StackTrace);
                throw;
            }
        }
Example #4
0
        public BidderDto UpdateBidder(BidderDto newBidder)
        {
            try
            {
                var entity = _context.Bidder.Include("address").Where(b => b.Id == newBidder.Id).FirstOrDefault();


                entity.firstName       = newBidder.firstName;
                entity.lastName        = newBidder.lastName;
                entity.tel             = newBidder.tel;
                entity.email           = newBidder.email;
                entity.fax             = newBidder.fax;
                entity.domaine         = newBidder.domaine;
                entity.typeEnterprise  = newBidder.typeEnterprise;
                entity.address.street  = newBidder.address.street;
                entity.address.zip     = newBidder.address.zip;
                entity.address.city    = newBidder.address.city;
                entity.address.region  = newBidder.address.region;
                entity.address.country = newBidder.address.country;

                _context.SaveChanges();

                return(newBidder);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message + e.StackTrace);
                throw;
            }
        }
Example #5
0
        public FetchOfferDto GetOffer(int offerId)
        {
            try
            {
                FetchOfferDto    fetchOffer;
                List <Diffusion> diffusions = new List <Diffusion>();
                List <Bidder>    bidders    = new List <Bidder>();
                BidderDto        bidderDto;

                var offer = _context.Offer.Include("categorie").Include("direction").Include("commission").Where(o => o.id == offerId).FirstOrDefault();
                diffusions = _context.Diffusion.Include("bidder").ToList();
                bidders    = _context.Bidder.Include("address").Include("plis").ToList();


                fetchOffer = new FetchOfferDto(offer.id, offer.code, offer.etat, offer.intitule, offer.description, offer.placeDepot, offer.dateLimit, offer.placeOpened, offer.dateOpened, offer.manager, offer.publish);

                fetchOffer.categorie.code     = offer.categorie.code;
                fetchOffer.categorie.libelle  = offer.categorie.libelle;
                fetchOffer.direction.code     = offer.direction.code;
                fetchOffer.direction.libelle  = offer.direction.libelle;
                fetchOffer.commission.code    = offer.commission.code;
                fetchOffer.commission.libelle = offer.commission.libelle;

                foreach (Diffusion diffusion in diffusions)
                {
                    foreach (Bidder bidder in bidders)
                    {
                        if (diffusion.offerId == offerId && diffusion.bidderId == bidder.Id)
                        {
                            bidderDto = new BidderDto(bidder.Id, bidder.firstName, bidder.lastName, bidder.email, bidder.tel, bidder.fax, bidder.domaine, bidder.typeEnterprise, bidder.address);

                            fetchOffer.bidders.Add(bidderDto);
                        }
                    }
                }

                return(fetchOffer);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message + e.StackTrace);
                throw;
            }
        }
        public FetchOfferDto GetOffer(int offerId)
        {
            try
            {
                FetchOfferDto fetchOffer;
                BidderDto     bidderDto;

                var offer = _context.Offer.Include("categorie").Include("direction").Include("commission").Where(o => o.id == offerId).FirstOrDefault();
                var plis  = _context.Plis.Include("bidder").Include("depouillement").ToList();

                fetchOffer = new FetchOfferDto(offer.id, offer.code, offer.etat, offer.intitule, offer.description, offer.placeDepot, offer.dateLimit, offer.placeOpened, offer.dateOpened, offer.manager, offer.publish);

                fetchOffer.categorie.code     = offer.categorie.code;
                fetchOffer.categorie.libelle  = offer.categorie.libelle;
                fetchOffer.direction.code     = offer.direction.code;
                fetchOffer.direction.libelle  = offer.direction.libelle;
                fetchOffer.commission.code    = offer.commission.code;
                fetchOffer.commission.libelle = offer.commission.libelle;

                foreach (Plis pli in plis)
                {
                    if (pli.depouillement.transCript == "Accepted" && pli.offerId == offerId)
                    {
                        bidderDto = new BidderDto(pli.bidder.Id, pli.bidder.firstName, pli.bidder.lastName, pli.bidder.email, pli.bidder.tel, pli.bidder.fax, pli.bidder.domaine, pli.bidder.typeEnterprise);
                        fetchOffer.bidders.Add(bidderDto);
                    }
                }

                return(fetchOffer);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message + e.StackTrace);
                throw;
            }
        }
Example #7
0
 public BidderDto Put(int id, [FromBody] BidderDto bidder)
 {
     Console.WriteLine(bidder);
     return(bidderRepository.UpdateBidder(bidder));
 }
Example #8
0
 public int Post([FromBody] BidderDto bid)
 {
     Console.WriteLine(bid);
     return(bidderRepository.PostBidder(bid));
 }