Пример #1
0
        private IEnumerable <IRecordView> GetTableActiveAuctionsPage()
        {
            try
            {
                LinkedList <BidSoftware.Shared.DTODefinition.ActiveAuction> li = new LinkedList <BidSoftware.Shared.DTODefinition.ActiveAuction>();
                BidSoftware.Shared.DTODefinition.ActiveAuction a;
                using (var ctx = new SI2_Entities())
                {
                    foreach (var auc in ctx.V_ActiveAuctions)
                    {
                        a             = new BidSoftware.Shared.DTODefinition.ActiveAuction();
                        a.SaleId      = auc.SaleId;
                        a.StartDate   = auc.StartDate;
                        a.EndDate     = auc.EndDate;
                        a.Description = auc.Description;
                        a.UserEmail   = auc.UserEmail;
                        a.Value       = Convert.ToDecimal(auc.Value);

                        li.AddLast(a);
                    }
                }
                return(li);
            }
            catch (Exception ex) { throw new DisconnectException(ex.Message, ex); }
        }
Пример #2
0
 public void AddBid(int saleId, string userName, decimal value)
 {
     try
     {
         using (var ctx = new SI2_Entities())
         {
             ctx.sp_addBid(saleId, userName, value);
         }
     }
     catch (Exception ex) { throw new DisconnectException(Utils.whatexception(ex).Message, ex); }
 }
Пример #3
0
 public void TestConnection()
 {
     //simplesmente para testar a ligação
     try
     {
         using (var ctx = new SI2_Entities())
         {
             var cond = ctx.ItemConditions.Where(p => p.Id == 1);
             if (cond == null)
             {
                 throw new DisconnectException("Não foi detectado condições de itens");
             }
         }
     }
     catch (Exception ex) { throw new DisconnectException(ex.Message, ex); }
 }
Пример #4
0
        public bool IsValidUser(Credentials creds)
        {
            try
            {
                //credentials = creds;

                using (var ctx = new SI2_Entities())
                {
                    ObjectParameter result = new ObjectParameter("result", typeof(int));

                    var  a  = ctx.sp_validateUser(creds.Username, creds.Password, result);
                    bool re = Convert.ToBoolean(result.Value);
                    return(re);
                }
            }
            catch (Exception ex) { throw new DisconnectException(ex.Message, ex); }
        }
Пример #5
0
        public Shared.Export.Auction ExportAuctionData(int auctionId)
        {
            List <BidSoftware.Shared.Export.Bid> lb = new List <BidSoftware.Shared.Export.Bid>();

            try
            {
                using (var ctx = new SI2_Entities())
                {
                    var auc = ctx.vAuctions.Where(a => a.SaleId == auctionId).SingleOrDefault();
                    if (auc == null)
                    {
                        throw new ArgumentException("Não existe o leilão com id " + auctionId);
                    }

                    var bids = ctx.vBids.Where(b => b.SaleId == auctionId);
                    foreach (var bi in bids)
                    {
                        BidSoftware.Shared.Export.Bid newbid = new BidSoftware.Shared.Export.Bid();
                        newbid.UserId   = bi.UserEmail;
                        newbid.Datetime = bi.Stamp.ToString();
                        lb.Add(newbid);
                    }

                    Shared.Export.Auction auctionExport = new Shared.Export.Auction()
                    {
                        Id   = "cenas entity",
                        Info = new Info()
                        {
                            InitialDate = auc.StartDate.ToString(), MinimumBid = auc.MinIncrement.ToString(), ReservationPrice = auc.SaleValue.ToString()
                        },
                        Bids = new Bids()
                        {
                            Num      = lb.Count().ToString(),
                            ArrayBid = lb.ToArray()
                        }
                    };
                    return(auctionExport);
                }
            }
            catch (Exception ex) { throw new DisconnectException(ex.Message, ex); }
        }