コード例 #1
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;
            }
        }
コード例 #2
0
        public int PostPlis(PlisDto plis)
        {
            try
            {
                Plis newPlis = new Plis(plis.code, plis.libelle, plis.dateDepot, plis.typeDepot);

                var bidder = _context.Bidder.Include("plis").Where(b => b.Id == plis.bidderId).FirstOrDefault();
                Console.WriteLine(bidder);

                var offer = _context.Offer.Include("plis").Where(o => o.id == plis.offerId).FirstOrDefault();
                Console.WriteLine(offer);

                bidder.plis.Add(newPlis);
                offer.plis.Add(newPlis);

                _context.SaveChanges();

                int newId = _context.Plis.Where(p => p.code == newPlis.code).FirstOrDefault().Id;
                return(newId);
            } catch (Exception e)
            {
                Debug.WriteLine(e.Message + e.StackTrace);
                throw;
            }
        }
コード例 #3
0
        public PlisDto getPlis(int id)
        {
            try
            {
                var     plis    = _context.Plis.Find(id);
                PlisDto plisDto = new PlisDto(plis.Id, plis.code, plis.libelle, plis.dateDepot, plis.typeDepot);

                return(plisDto);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message + e.StackTrace);
                throw;
            }
        }
コード例 #4
0
        public bool updatePlis(int id, PlisDto plisDto)
        {
            try
            {
                var plis = _context.Plis.Find(id);

                plis.code      = plisDto.code;
                plis.libelle   = plisDto.libelle;
                plis.dateDepot = plisDto.dateDepot;
                plis.typeDepot = plisDto.typeDepot;

                _context.SaveChanges();

                var plisModif = _context.Plis.Find(id);

                return(true);
            } catch (Exception e)
            {
                Debug.WriteLine(e.Message + e.StackTrace);
                throw;
            }
        }
コード例 #5
0
 public bool Put(int id, [FromBody] PlisDto plis)
 {
     return(plisRepository.updatePlis(id, plis));
 }
コード例 #6
0
 public int Post([FromBody] PlisDto plis)
 {
     Console.WriteLine(plis);
     return(plisRepository.PostPlis(plis));
 }