protected void LoadItems()
 {
     phHasItems.Visible   = true;
     phHasNoItems.Visible = false;
     //DateTime from, to = new DateTime();
     //DateTime.TryParse(datepickerFrom.Text.ToString(), out from);
     //DateTime.TryParse(datepickerTo.Text.ToString(), out to);
     dgBids.VirtualItemCount = BidController.GetSupplierBids(SupplierId, Action, FromDate, ToDate, BidId).Count;
     if (dgBids.VirtualItemCount == 0)
     {
         phHasItems.Visible   = false;
         phHasNoItems.Visible = true;
         lblNoItems.Text      = BidString.GetText(@"MessageNoBidsFound");
     }
     else
     {
         phHasItems.Visible   = true;
         phHasNoItems.Visible = false;
         if (dgBids.PageSize * dgBids.CurrentPageIndex > dgBids.VirtualItemCount)
         {
             dgBids.CurrentPageIndex         = 0;
             hfCurrentPageIndex_dgBids.Value = dgBids.CurrentPageIndex.ToString();
         }
         List <BidUI> coll = BidController.GetSupplierBids(SupplierId, Action, FromDate, ToDate, BidId, dgBids.PageSize, dgBids.CurrentPageIndex);
         BindList(coll);
     }
 }
Пример #2
0
        public async void Test1()
        {
            var mockBidService = new Mock <IBidService>();

            mockBidService.Setup(s => s.Place(new BidRequestDto
            {
                Amount        = 60,
                AuctionItemId = 1,
                BidTime       = DateTime.Now
            })).ReturnsAsync(new BidResponse
            {
                BidRequestDto = new BidRequestDto
                {
                    Amount        = 60,
                    AuctionItemId = 1,
                    BidTime       = DateTime.Now
                },
                CurrentBidCount = 2,
                Message         = "Ok",
                Success         = true
            });

            var controller = new BidController(mockBidService.Object);
            //await controller.PostAsync(new BidRequestDto
            //{
            //    Amount = 60,
            //    AuctionItemId = 1,
            //    BidTime = DateTime.Now
            //}).Result;
        }
Пример #3
0
        bool saveDeal(Int64 bidId)
        {
            var order = Order.FetchByBidId(bidId);

            if (order != null && order.SupplierId > 0)
            {
                return(false);
            }

            decimal TotalPrice = order.TotalPrice;
            var     discount   = BidController.GetDiscountForUser(TotalPrice, order.AppUserId);
            var     supplier   = AppSupplier.FetchByID(312);
            string  response   = "";

            decimal PriceAfterDiscount = Convert.ToDecimal(discount["PriceAfterDiscount"]);
            decimal PrecentDiscount    = Convert.ToDecimal(discount["PrecentDiscount"]);
            Int64?  CampaignId         = Convert.ToInt64(discount["CampaignId"]);
            var     paymentDetails     = new PaymentDetails
            {
                Amount        = (float)PriceAfterDiscount * 100,
                CreditId      = order.Transaction,
                Exp           = order.ExpiryDate,
                AuthNumber    = order.AuthNumber,
                NumOfPayments = order.NumOfPayments,
                SupplierToken = supplier.MastercardCode
            };

            try
            {
                response = CreditGuardManager.CreateMPITransaction(paymentDetails);
            }
            catch
            {
                Notification.SendNotificationAppUserCreditRejected(order.AppUserId, bidId);
                return(false);
            }
            if (response != "000")
            {
                Notification.SendNotificationAppUserCreditRejected(order.AppUserId, bidId);
                return(false);
            }
            order.IsSendRecived = false;
            if (CampaignId != 0)
            {
                order.CampaignId = CampaignId;
            }
            order.TotalPrice         = TotalPrice;
            order.PriceAfterDiscount = PriceAfterDiscount;
            order.PrecentDiscount    = PrecentDiscount;
            // order.SpecialInstructions = special_instructions;
            order.UserPaySupplierStatus = UserPaymentStatus.Payed;
            order.SupplierId            = 312;
            order.Save();
            var bid = Bid.FetchByID(bidId);

            bid.IsActive = false;
            bid.Save();
            Notification.SendNotificationAppUserSupplierApproved(Snoopi.web.Localization.PushStrings.GetText("SupplierApproved"), bid.AppUserId.Value, order.OrderId);
            return(true);
        }
Пример #4
0
        public void Add_Bid_Test()
        {
            //Arrange
            Mock <ILotsRepository> mock = new Mock <ILotsRepository>();

            mock.Setup(m => m.Lots).Returns(new[] {
                new Lot {
                    LotID = 1, Name = "P1", IsCompleted = false
                },
                new Lot {
                    LotID = 2, Name = "P2", IsCompleted = false
                },
                new Lot {
                    LotID = 3, Name = "P3", IsCompleted = false
                },
                new Lot {
                    LotID = 4, Name = "P4", IsCompleted = false
                },
            }.AsQueryable());
            var target = new BidController(mock.Object);

            //Act
            var result = target.Add(new LotModel
            {
                BidAmount = 10,
                Lot       = mock.Object.Lots.First(),
                NumOnPage = 1
            });
            //Arrange
        }
Пример #5
0
        public static OrderUI GetOrderById(Int64 OrderId, Int64 SupplierId = 0)
        {
            Query q = new Query(Order.TableSchema);

            // q.Join(JoinType.InnerJoin, Order.TableSchema, Order.Columns.BidId, Order.TableSchema.SchemaName,
            //  Offer.TableSchema, Offer.Columns.BidId, Offer.TableSchema.SchemaName);


            q.Join(JoinType.InnerJoin, Order.TableSchema, Order.Columns.SupplierId, Order.TableSchema.SchemaName,
                   AppSupplier.TableSchema, AppSupplier.Columns.SupplierId, AppSupplier.TableSchema.SchemaName);
            q.Join(JoinType.InnerJoin, Order.TableSchema, Order.Columns.AppUserId, Order.TableSchema.SchemaName,
                   AppUser.TableSchema, AppUser.Columns.AppUserId, AppUser.TableSchema.SchemaName);
            q.Join(JoinType.InnerJoin, AppUser.TableSchema, AppUser.Columns.CityId, AppUser.TableSchema.SchemaName,
                   City.TableSchema, City.Columns.CityId, City.TableSchema.SchemaName);
            q.OrderBy(Order.TableSchema.SchemaName, Order.Columns.CreateDate, SortDirection.DESC);
            q.Select(Order.TableSchema.SchemaName, Order.Columns.OrderId, Order.Columns.OrderId, true);
            q.AddSelect(AppSupplier.TableSchema.SchemaName, AppSupplier.Columns.BusinessName, AppSupplier.Columns.BusinessName);
            q.AddSelect(AppSupplier.TableSchema.SchemaName, AppSupplier.Columns.SupplierId, AppSupplier.Columns.SupplierId);
            q.AddSelect(Order.TableSchema.SchemaName, Order.Columns.CreateDate, Order.Columns.CreateDate);
            q.AddSelect(Order.TableSchema.SchemaName, Order.Columns.TotalPrice, Order.Columns.TotalPrice);
            q.AddSelect(Order.TableSchema.SchemaName, Order.Columns.BidId, Order.Columns.BidId);
            q.AddSelect(Order.TableSchema.SchemaName, Order.Columns.ReceivedDate, Order.Columns.ReceivedDate);
            q.AddSelect(City.TableSchema.SchemaName, City.Columns.CityName, City.Columns.CityName);
            q.AddSelect(Order.TableSchema.SchemaName, Order.Columns.Gifts, Order.Columns.Gifts);
            q.AddSelect(Order.TableSchema.SchemaName, Order.Columns.SuppliedDate, Order.Columns.SuppliedDate);
            q.AddSelect(Order.TableSchema.SchemaName, Order.Columns.AppUserId, Order.Columns.AppUserId);
            q.AddSelect(Order.TableSchema.SchemaName, Order.Columns.SpecialInstructions, Order.Columns.SpecialInstructions);
            q.AddSelect(Order.TableSchema.SchemaName, Order.Columns.IsSendRecived, Order.Columns.IsSendRecived);
            q.Where(Order.TableSchema.SchemaName, Order.Columns.OrderId, WhereComparision.EqualsTo, OrderId);

            if (SupplierId != 0)
            {
                q.AddWhere(AppSupplier.TableSchema.SchemaName, AppSupplier.Columns.SupplierId, WhereComparision.EqualsTo, SupplierId);
            }
            OrderUI orderUI = null;

            using (DataReaderBase reader = q.ExecuteReader())
            {
                if (reader.Read())
                {
                    orderUI = new OrderUI();
                    orderUI.SupplierName        = (reader[AppSupplier.Columns.BusinessName] != null ? reader[AppSupplier.Columns.BusinessName].ToString() : "");
                    orderUI.SupplierId          = (reader[AppSupplier.Columns.SupplierId] != null ? Int64.Parse(reader[AppSupplier.Columns.SupplierId].ToString()) : 0);
                    orderUI.OrderId             = (reader[Order.Columns.OrderId] != null ? Int64.Parse(reader[Order.Columns.OrderId].ToString()) : 0);
                    orderUI.OrderDate           = (reader[Order.Columns.CreateDate] != null ? DateTime.Parse(reader[Order.Columns.CreateDate].ToString()).ToLocalTime() : DateTime.MinValue);
                    orderUI.Price               = (reader[Order.Columns.TotalPrice] != null ? decimal.Parse(reader[Order.Columns.TotalPrice].ToString()) : 0);
                    orderUI.ReceviedDate        = (reader[Order.Columns.ReceivedDate] != null && (reader[Order.Columns.ReceivedDate]).ToString() != "" ? (DateTime?)Convert.ToDateTime(reader[Order.Columns.ReceivedDate]).ToLocalTime() : null);
                    orderUI.LstProduct          = BidController.GetProductsByBid(reader[Order.Columns.BidId] != null ? Int64.Parse(reader[Order.Columns.BidId].ToString()) : 0, orderUI.SupplierId);
                    orderUI.City                = (reader[City.Columns.CityName] != null ? reader[City.Columns.CityName].ToString() : "");
                    orderUI.user                = AppUser.FetchByID(Int64.Parse(reader[Order.Columns.AppUserId].ToString()));
                    orderUI.SuppliedDate        = (reader[Order.Columns.SuppliedDate] != null && (reader[Order.Columns.SuppliedDate]).ToString() != "" ? (DateTime?)Convert.ToDateTime(reader[Order.Columns.SuppliedDate]).ToLocalTime() : null);
                    orderUI.Gift                = (reader[Order.Columns.Gifts] != null ? reader[Order.Columns.Gifts].ToString() : "");
                    orderUI.SpecialInstructions = (reader[Order.Columns.SpecialInstructions] != null ? reader[Order.Columns.SpecialInstructions].ToString() : "");
                    orderUI.BidId               = (reader[Order.Columns.BidId] != null ? Int64.Parse(reader[Order.Columns.BidId].ToString()) : 0);
                    orderUI.IsSendReceived      = (reader[Order.Columns.IsSendRecived] != null) ? Convert.ToBoolean(reader[Order.Columns.IsSendRecived]) : false;
                }
            }
            return(orderUI);
        }
Пример #6
0
        public override void Get(HttpRequest Request, HttpResponse Response, params string[] PathParams)
        {
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetMaxAge(TimeSpan.Zero);

            Int64   AppUserId;
            decimal TotalPrice;

            if (IsAuthorizedRequest(Request, Response, false, out AppUserId))
            {
                try
                {
                    Response.ContentType = @"application/json";
                    using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
                    {
                        using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                        {
                            List <BidProductUI> lstProduct = BidController.GetLastShoppingCart(AppUserId, out TotalPrice);
                            jsonWriter.WriteStartObject();
                            jsonWriter.WritePropertyName(@"products");
                            jsonWriter.WriteStartArray();

                            foreach (BidProductUI item in lstProduct)
                            {
                                jsonWriter.WriteStartObject();

                                jsonWriter.WritePropertyName(@"product_id");
                                jsonWriter.WriteValue(item.ProductId);
                                jsonWriter.WritePropertyName(@"product_name");
                                jsonWriter.WriteValue(item.ProductName);
                                jsonWriter.WritePropertyName(@"product_amount");
                                jsonWriter.WriteValue(item.Amount);
                                jsonWriter.WritePropertyName(@"order_amount");
                                jsonWriter.WriteValue(item.Amount);
                                jsonWriter.WritePropertyName(@"product_image");
                                jsonWriter.WriteValue(item.ProductImage);
                                jsonWriter.WritePropertyName(@"recomended_price");
                                jsonWriter.WriteValue(item.RecomendedPrice);

                                // jsonWriter.WritePropertyName(@"product_price");
                                // jsonWriter.WriteValue(item.Price);

                                jsonWriter.WriteEndObject();
                            }

                            jsonWriter.WriteEndArray();

                            //jsonWriter.WritePropertyName(@"total_price");
                            //jsonWriter.WriteValue(TotalPrice);

                            jsonWriter.WriteEndObject();
                        }
                    }
                }
                catch (Exception) { }
            }
        }
Пример #7
0
        public void Bid_ModelStateError_Test()
        {
            //Arrange
            Mock <ICategoriesRepository> category = new Mock <ICategoriesRepository>();

            category.Setup(m => m.Categories).Returns(new[]
            {
                new Category
                {
                    CategoryId   = 1,
                    CategoryName = "Cat1",
                },
                new Category
                {
                    CategoryId   = 1,
                    CategoryName = "Cat2",
                },
                new Category
                {
                    CategoryId   = 1,
                    CategoryName = "Cat3",
                }
            }.AsQueryable());
            Mock <ILotsRepository> mock = new Mock <ILotsRepository>();

            mock.Setup(m => m.Lots).Returns(new[]
            {
                new Lot {
                    LotID = 1, Name = "P1", Category = category.Object.Categories.ToList()[0]
                },
                new Lot {
                    LotID = 2, Name = "P2", Category = category.Object.Categories.ToList()[1]
                },
                new Lot {
                    LotID = 3, Name = "P3", Category = category.Object.Categories.ToList()[0]
                },
                new Lot {
                    LotID = 4, Name = "P4", Category = category.Object.Categories.ToList()[1]
                },
                new Lot {
                    LotID = 5, Name = "P5", Category = category.Object.Categories.ToList()[2]
                }
            }.AsQueryable());
            BidController controller = new BidController(mock.Object);

            controller.ModelState.AddModelError("test", "test");
            //Act
            ActionResult result = controller.Add(new LotModel()
            {
                BidAmount = 10,
                Lot       = mock.Object.Lots.First()
            });

            // Assert
            Assert.IsInstanceOfType(result, typeof(PartialViewResult));
        }
Пример #8
0
 public bool IsBidWon(Bid bid)
 {
     try
     {
         return(BidController.Instance().IsBidWon(bid));
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
Пример #9
0
 public bool BidExpired(int productId)
 {
     try
     {
         return(BidController.Instance().BidExpired(productId));
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
Пример #10
0
 public bool SetWinnersForProducts()
 {
     try
     {
         return(BidController.Instance().SetWinnersForProducts());
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
Пример #11
0
        protected void LoadItems(bool fromDb)
        {
            if (!HasEditPermission)
            {
                dgBids.Columns[dgBids.Columns.Count - 1].Visible = false;
            }
            DateTime from = new DateTime(), to = new DateTime();

            DateTime.TryParse(dpSearchCreateDateFrom.Value.ToString(), out from);
            DateTime.TryParse(dpSearchCreateDateTo.Value.ToString(), out to);
            Int64 _BidId = -1;

            if (txtBidNumber.Text != "")
            {
                Int64.TryParse(txtBidNumber.Text, out _BidId);
            }
            if (fromDb)
            {
                //    au = BidController.GetUntakenBidsTempForCampaign(filterSearch, from, to, txtSearchPhone.Text, txtCustomerId.Text, _BidId, txtCityName.Text);
                au = BidController.GetUntakenBids(filterSearch, from, to, txtSearchPhone.Text, txtCustomerId.Text, _BidId, txtCityName.Text);

                ViewState["au"] = au;
            }
            dgBids.VirtualItemCount = au.Count;
            if (dgBids.VirtualItemCount == 0)
            {
                phHasItems.Visible   = false;
                phHasNoItems.Visible = true;
                lblNoItems.Text      = BidString.GetText(@"MessageNoBidsFound");
            }
            else
            {
                phHasItems.Visible   = true;
                phHasNoItems.Visible = false;
                if (dgBids.PageSize * dgBids.CurrentPageIndex > dgBids.VirtualItemCount)
                {
                    dgBids.CurrentPageIndex         = 0;
                    hfCurrentPageIndex_dgBids.Value = dgBids.CurrentPageIndex.ToString();
                }
                if (filterSearch == null)
                {
                    //lblSumAbandonedBidsWithOffers.Text = au.Count(b => b.OfferNum > 0 && b.OrderDate == (DateTime?)null && b.EndDate < DateTime.Now).ToString();
                    //lblSumAbandonedBidsWithOutOffers.Text = au.Count(b => b.OfferNum == 0 && b.OrderDate == (DateTime?)null && b.EndDate < DateTime.Now).ToString();
                    //lblSumActiveBids.Text = au.Count(b => b.EndDate >= DateTime.Now).ToString();
                    //lblSumPurchaseBids.Text = au.Count(b => b.OrderDate != (DateTime?)null).ToString();
                }
                else
                {
                    dgBids.VirtualItemCount = au.Count();
                }
                //        List<BidUI> app_users = BidController.GetUntakenBids(filterSearch, from, to, txtSearchPhone.Text, txtCustomerId.Text, _BidId, txtCityName.Text, dgBids.PageSize, dgBids.CurrentPageIndex);
                BindList(au);
            }
        }
Пример #12
0
        // TODO: fix all the return list methods (try to return list of bidDtos)

        public void MakeBid(int userId, int productId, int coins)
        {
            try
            {
                BidController.Instance().MakeBid(userId, productId, coins);
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
Пример #13
0
 public IList <Bid> GetAllEarnedBids()
 {
     try
     {
         return(BidController.Instance().GetAllEarnedBids());
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
Пример #14
0
        public async Task Initialize()
        {
            // create test user
            var user = new AppIdentityUser
            {
                Id               = "TestUser",
                UserName         = "******",
                Email            = "*****@*****.**",
                TwoFactorEnabled = true
            };

            var userManager = this._serviceProvider.GetRequiredService <UserManager <AppIdentityUser> >();
            await userManager.CreateAsync(user, "Pass@word1");

            var bettingCurrent = new BettingModel()
            {
                Status       = BettingStatus.Continue,
                BettingId    = 1,
                ExchangeRate = 1000,
                StartDate    = DateTime.Now,
                FinishDate   = DateTime.Now.AddDays(1)
            };
            var bettingDone = new BettingModel()
            {
                Status       = BettingStatus.Waiting,
                BettingId    = 2,
                ExchangeRate = 1000,
                StartDate    = DateTime.Now,
                FinishDate   = DateTime.Now.AddDays(1)
            };
            var bettingService = this._serviceProvider.GetRequiredService <IGenericRepository <BettingModel> >();

            bettingService.Create(bettingCurrent);
            bettingService.Create(bettingDone);

            var urlHelperMock = new Mock <IBitcoinWalletService>();

            urlHelperMock.Setup(service => service.GetAddressById(It.IsAny <int>())).Returns(
                () => BitcoinAddress.Create("mhheFUrieWV2zVsdWXNZkqSmeSVjkbXWer", Network.TestNet));
            this.bidController = new BidController(
                this._serviceProvider.GetRequiredService <IBidService>(),
                this._serviceProvider.GetRequiredService <IBettingService>(),
                urlHelperMock.Object,
                userManager);

            // sign in test user
            var httpContext = this._serviceProvider.GetRequiredService <IHttpContextAccessor>().HttpContext;

            httpContext.User = new ClaimsPrincipal(
                new ClaimsIdentity(new GenericIdentity(user.Email), new[] { new Claim("ID", user.Id) }));
            httpContext.RequestServices = this._serviceProvider;
            this.bidController.ControllerContext.HttpContext = httpContext;
        }
Пример #15
0
        public BidDto GetBidById(int bidId)
        {
            try
            {
                var bidDb = BidController.Instance().GetBidByIdWithAllObjects(bidId);

                return(MapDbBidToBidDto(bidDb));
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
Пример #16
0
        public IList <BidDto> GetAllBidsByProductId(int productId)
        {
            try
            {
                var bids = BidController.Instance().GetAllBidsByProductId(productId);

                return(TransferCollectionData(bids));
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
Пример #17
0
        protected void btnExport_Click(object sender, EventArgs e)
        {
            System.Data.DataTable dt = new System.Data.DataTable();

            dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"BidId"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"StartDate"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"EndDate"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"OffersCount"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"Products"), typeof(string)));
            if (bidType != BidType.BidCount || bidType != BidType.BidPurchase)
            {
                dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"OrderDate"), typeof(string)));
            }
            List <BidUI> coll;

            if (AllBids)
            {
                coll = BidController.GetAllBidByCustomerTypeAndBidType(customerType, bidType, BidLeave, 0, 0);
            }
            else
            {
                coll = BidController.GetAllBidByCustomerIdAndBidType(CustomerId, customerType, bidType, 0, 0);
            }
            foreach (BidUI Bid in coll)
            {
                int i = 0;
                System.Data.DataRow row = dt.NewRow();
                row[i++] = Bid.BidId;
                row[i++] = "\"" + Bid.StartDate + "\"";
                row[i++] = "\"" + Bid.EndDate + "\"";
                row[i++] = Bid.OfferNum;
                row[i++] = Bid.Products.Replace("<br>", ",");
                if (bidType != BidType.BidCount || bidType != BidType.BidPurchase)
                {
                    row[i++] = "\"" + Bid.OrderDate + "\"";
                }
                dt.Rows.Add(row);
            }

            SpreadsheetWriter ex = SpreadsheetWriter.FromDataTable(dt, false, true);

            Response.Clear();
            Response.AddHeader(@"content-disposition", @"attachment;filename=MyBidsExport_" + DateTime.UtcNow.ToString(@"yyyy_MM_dd_HH_mm_ss") + "." + ex.FileExtension);
            Response.Charset         = @"UTF-8";
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.ContentType = ex.FileContentType;
            Response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble());
            Response.Write(ex.ToString());
            Response.End();
        }
Пример #18
0
        protected void LoadItems()
        {
            phHasItems.Visible   = true;
            phHasNoItems.Visible = false;
            if (dgCustomers.PageSize * dgCustomers.CurrentPageIndex > dgCustomers.VirtualItemCount)
            {
                dgCustomers.CurrentPageIndex         = 0;
                hfCurrentPageIndex_dgCustomers.Value = dgCustomers.CurrentPageIndex.ToString();
            }
            CustomerUI customer = BidController.GetCustomerData(CustomerId, customerType);

            Master.PageTitle = customerType == CustomerType.AppUser ? BidString.GetText(@"CustomersPageTitle") + customer.CustomerName : BidString.GetText(@"CustomersTempPageTitle");
            BindList(customer);
        }
Пример #19
0
        public void Bid_ModelStateValid_Test()
        {
            //Arrange
            Mock <ICategoriesRepository> category = new Mock <ICategoriesRepository>();

            category.Setup(m => m.Categories).Returns(new[]
            {
                new Category
                {
                    CategoryId   = 1,
                    CategoryName = "Cat1",
                },
                new Category
                {
                    CategoryId   = 1,
                    CategoryName = "Cat2",
                },
                new Category
                {
                    CategoryId   = 1,
                    CategoryName = "Cat3",
                }
            }.AsQueryable());
            Mock <ILotsRepository> mock = new Mock <ILotsRepository>();

            mock.Setup(m => m.Lots).Returns(new[]
            {
                new Lot {
                    LotID = 1, Name = "P1", Category = category.Object.Categories.ToList()[0], EndTime = new DateTime(2016)
                },
            }.AsQueryable());
            BidController controller = new BidController(mock.Object);

            controller.ModelState.Clear();

            //Act
            ActionResult result = controller.Add(new LotModel()
            {
                BidAmount = 10,
                Lot       = mock.Object.Lots.First(),
            });

            // Assert
            Assert.IsInstanceOfType(result, typeof(PartialViewResult));
        }
Пример #20
0
        public void TestInitialize()
        {
            userCtrl = new UserController();
            itemCtrl = new ItemController();
            bidCtrl  = new BidController();

            //TestSeller
            testSeller = new User
            {
                UserName  = "******",
                FirstName = "FirstName",
                LastName  = "LastName",
                Password  = "******",
                Email     = "*****@*****.**",
                Admin     = false
            };
            userCtrl.CreateUser(testSeller);

            //TestBidder
            testBidder = new User
            {
                UserName  = "******",
                FirstName = "TestFirstName",
                LastName  = "TestLastName",
                Password  = "******",
                Email     = "*****@*****.**",
                Admin     = false
            };
            userCtrl.CreateUser(testBidder);

            //TestItem
            testSeller = userCtrl.Login(testSeller.UserName, testSeller.Password);
            int itemId = itemCtrl.CreateItem(
                "_Test__Item",
                "This is a test item",
                10,
                1,
                testSeller.LoginToken.SecureToken,
                3,
                "");

            testItem = itemCtrl.GetItemById(itemId);

            testSeller.Password = "******";
        }
Пример #21
0
        protected void btnExport_Click(object sender, EventArgs e)
        {
            System.Data.DataTable dt = new System.Data.DataTable();

            dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"BidId"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"StartDate"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"EndDate"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"TotalPrice"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"Products"), typeof(string)));
            if (Action == "Win" || Action == "Offers")
            {
                dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"OrderDate1"), typeof(string)));
            }


            List <BidUI> coll = BidController.GetSupplierBids(SupplierId, Action, FromDate, ToDate, BidId);

            foreach (BidUI bid in coll)
            {
                int i = 0;
                System.Data.DataRow row = dt.NewRow();
                row[i++] = bid.BidId;
                row[i++] = "\"" + bid.StartDate + "\"";
                row[i++] = "\"" + bid.EndDate + "\"";
                row[i++] = bid.Price;
                row[i++] = (bid.LstProduct.Count == 0 || bid.LstProduct == null) ? "" : String.Join(", ", bid.LstProduct.Select(o => o.ProductName));
                if (Action == "Win" || Action == "Offers")
                {
                    row[i++] = "\"" + bid.OrderDate + "\"";
                }
                dt.Rows.Add(row);
            }
            SpreadsheetWriter ex = SpreadsheetWriter.FromDataTable(dt, false, true);

            Response.Clear();
            Response.AddHeader(@"content-disposition", @"attachment;filename=Supplier" + SupplierId + Action + "BidsExport_" + DateTime.UtcNow.ToString(@"yyyy_MM_dd_HH_mm_ss") + "." + ex.FileExtension);
            Response.Charset         = @"UTF-8";
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.ContentType = ex.FileContentType;
            Response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble());
            Response.Write(ex.ToString());
            Response.End();
        }
Пример #22
0
 protected void LoadItems()
 {
     if (!HasEditPermission)
     {
         dgMyBids.Columns[dgMyBids.Columns.Count - 1].Visible = false;
     }
     if (AllBids)
     {
         dgMyBids.VirtualItemCount = Convert.ToInt32(BidController.GetCountAllBidByCustomerTypeAndBidType(customerType, bidType, BidLeave));
     }
     else
     {
         dgMyBids.VirtualItemCount = Convert.ToInt32(BidController.GetCountBidByCustomerIdAndBidType(CustomerId, customerType, bidType));
     }
     if (dgMyBids.VirtualItemCount == 0)
     {
         phHasItems.Visible   = false;
         phHasNoItems.Visible = true;
         lblNoItems.Text      = BidString.GetText(@"MessageNoBidsFound");
     }
     else
     {
         phHasItems.Visible   = true;
         phHasNoItems.Visible = false;
         if (dgMyBids.PageSize * dgMyBids.CurrentPageIndex > dgMyBids.VirtualItemCount)
         {
             dgMyBids.CurrentPageIndex         = 0;
             hfCurrentPageIndex_dgMyBids.Value = dgMyBids.CurrentPageIndex.ToString();
         }
         if (AllBids)
         {
             List <BidUI> coll = BidController.GetAllBidByCustomerTypeAndBidType(customerType, bidType, BidLeave, dgMyBids.PageSize, dgMyBids.CurrentPageIndex);
             BindList(coll);
         }
         else
         {
             List <BidUI> coll = BidController.GetAllBidByCustomerIdAndBidType(CustomerId, customerType, bidType, dgMyBids.PageSize, dgMyBids.CurrentPageIndex);
             BindList(coll);
         }
     }
 }
Пример #23
0
        public static List <OrderUI> GetOrderSupplierHistoryExcel(Int64 SupplierId, DateTime?StartDate = null, DateTime?EndDate = null)
        {
            Query q = new Query(Order.TableSchema);

            q.Join(JoinType.InnerJoin, Order.TableSchema, Order.Columns.SupplierId, Order.TableSchema.SchemaName,
                   AppSupplier.TableSchema, AppSupplier.Columns.SupplierId, AppSupplier.TableSchema.SchemaName);
            q.OrderBy(Order.TableSchema.SchemaName, Order.Columns.CreateDate, SortDirection.DESC);
            q.Select(Order.TableSchema.SchemaName, Order.Columns.OrderId, Order.Columns.OrderId, true);
            q.AddSelect(AppSupplier.TableSchema.SchemaName, AppSupplier.Columns.BusinessName, AppSupplier.Columns.BusinessName);
            q.AddSelect(AppSupplier.TableSchema.SchemaName, AppSupplier.Columns.SupplierId, AppSupplier.Columns.SupplierId);
            q.AddSelect(Order.TableSchema.SchemaName, Order.Columns.CreateDate, Order.Columns.CreateDate);
            q.AddSelect(Order.TableSchema.SchemaName, Order.Columns.BidId, Order.Columns.BidId);
            q.AddSelect(Order.TableSchema.SchemaName, Order.Columns.TotalPrice, Order.Columns.TotalPrice);
            q.AddSelect(Order.TableSchema.SchemaName, Order.Columns.TransactionResponseCode, Order.Columns.TransactionResponseCode);
            q.Where(AppSupplier.TableSchema.SchemaName, AppSupplier.Columns.SupplierId, WhereComparision.EqualsTo, SupplierId);
            if (StartDate != null && EndDate != null)
            {
                q.AddWhere(Order.TableSchema.SchemaName, Order.Columns.CreateDate, WhereComparision.GreaterThanOrEqual, StartDate);
                q.AddWhere(Order.TableSchema.SchemaName, Order.Columns.CreateDate, WhereComparision.LessThanOrEqual, EndDate.Value.AddDays(1));
            }
            List <OrderUI> LstOrder = new List <OrderUI>();

            using (DataReaderBase reader = q.ExecuteReader())
            {
                while (reader.Read())
                {
                    OrderUI orderUI = new OrderUI();
                    orderUI.SupplierName = (reader[AppSupplier.Columns.BusinessName] != null ? reader[AppSupplier.Columns.BusinessName].ToString() : "");
                    orderUI.SupplierId   = (reader[AppSupplier.Columns.SupplierId] != null ? Int64.Parse(reader[AppSupplier.Columns.SupplierId].ToString()) : 0);
                    orderUI.OrderId      = (reader[Order.Columns.OrderId] != null ? Int64.Parse(reader[Order.Columns.OrderId].ToString()) : 0);
                    orderUI.OrderDate    = (reader[Order.Columns.CreateDate] != null ? DateTime.Parse(reader[Order.Columns.CreateDate].ToString()).ToLocalTime() : DateTime.MinValue);
                    orderUI.BidId        = (reader[Order.Columns.BidId] != null ? Int64.Parse(reader[Order.Columns.BidId].ToString()) : 0);
                    orderUI.Price        = (reader[Order.Columns.TotalPrice] != null ? Int64.Parse(reader[Order.Columns.TotalPrice].ToString()) : 0);
                    orderUI.LstProduct   = BidController.GetProductsByBid(orderUI.BidId);
                    LstOrder.Add(orderUI);
                }
            }
            return(LstOrder);
        }
Пример #24
0
        public void GetBidsTest()

        {
            //Arrange
            BidController bCtr = new BidController();
            bool          NotEmpty;

            //Act
            List <BidData> bidData = bCtr.GetBids(5);

            if (bidData.Count > 0)
            {
                NotEmpty = true;
            }
            else
            {
                NotEmpty = false;
            }

            //Assert
            Assert.IsTrue(NotEmpty);
        }
Пример #25
0
        public override void Get(HttpRequest Request, HttpResponse Response, params string[] PathParams)
        {
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetMaxAge(TimeSpan.Zero);

            try
            {
                Int64 AppUserId;
                Int64 offer_id = (Request.QueryString["offer_id"] != null ? Int64.Parse(Request.QueryString["offer_id"].ToString()) : 0);
                if (IsAuthorizedRequest(Request, Response, true, out AppUserId))
                {
                    Response.ContentType = @"application/json";
                    using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
                    {
                        using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                        {
                            Dictionary <string, string> result = BidController.GetDiscount(offer_id, AppUserId);

                            jsonWriter.WriteStartObject();

                            jsonWriter.WritePropertyName(@"total_price");
                            jsonWriter.WriteValue(result["TotalPrice"]);
                            jsonWriter.WritePropertyName(@"price_after_discount");
                            jsonWriter.WriteValue(result["PriceAfterDiscount"]);
                            jsonWriter.WritePropertyName(@"gift_content");
                            jsonWriter.WriteValue(result["GiftContent"]);
                            jsonWriter.WritePropertyName(@"campaign_id");
                            jsonWriter.WriteValue(result["CampaignId"]);

                            jsonWriter.WriteEndObject();
                        }
                    }
                }
            }
            catch (Exception) { }
        }
Пример #26
0
        private void HandleAll(HttpRequest Request, HttpResponse Response, params string[] PathParams)
        {
            if (!Request.IsLocal)
            {
                Http.Respond404(true);
            }

            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetMaxAge(TimeSpan.Zero);

            if (PathParams[0] == @"rematch")
            {
                using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
                {
                    using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                    {
                        jsonWriter.WriteStartObject();
                        try
                        {
                            jsonWriter.WritePropertyName(@"success");
                            jsonWriter.WriteValue(true);
                        }
                        catch (System.Exception ex)
                        {
                            jsonWriter.WritePropertyName(@"error");
                            jsonWriter.WriteValue(@"unknown");
                            jsonWriter.WritePropertyName(@"description");
                            jsonWriter.WriteValue(ex.ToString());
                        }
                        jsonWriter.WriteEndObject();
                    }
                }
            }
            else if (PathParams[0] == @"clean_tokens")
            {
                using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
                {
                    using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                    {
                        jsonWriter.WriteStartObject();
                        try
                        {
                            AuthTokens.DeleteAllExpired();


                            jsonWriter.WritePropertyName(@"success");
                            jsonWriter.WriteValue(true);
                        }
                        catch (System.Exception ex)
                        {
                            jsonWriter.WritePropertyName(@"error");
                            jsonWriter.WriteValue(@"unknown");
                            jsonWriter.WritePropertyName(@"description");
                            jsonWriter.WriteValue(ex.ToString());
                        }
                        jsonWriter.WriteEndObject();
                    }
                }
            }
            else if (PathParams[0] == @"offer")
            {
                //using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
                //{
                //    using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                //    {
                //        jsonWriter.WriteStartObject();
                //        try
                //        {
                //            Query qry = new Query(Bid.TableSchema);
                //            qry.Where(Bid.Columns.IsSendOffer, WhereComparision.EqualsTo, false);
                //            qry.AddWhere(Bid.Columns.EndDate, WhereComparision.LessThan, DateTime.UtcNow);

                //            BidCollection bidCollection = BidCollection.FetchByQuery(qry);


                //            Query.New<Bid>().Where(Bid.Columns.IsSendOffer, WhereComparision.EqualsTo, false)
                //                .AddWhere(Bid.Columns.EndDate, WhereComparision.LessThan, DateTime.UtcNow)
                //                .Update(Bid.Columns.IsSendOffer, true)
                //                .Execute();

                //            foreach (Bid item in bidCollection)
                //            {
                //                Query q = new Query(Offer.TableSchema);
                //                q.Where(Offer.Columns.BidId, WhereComparision.EqualsTo, item.BidId);

                //                OfferCollection offerCollection = OfferCollection.FetchByQuery(q);
                //                if (offerCollection != null && offerCollection.Count > 0)
                //                {
                //                    if (item.AppUserId != null && item.AppUserId != 0)
                //                    {
                //                        Notification.SendNotificationAppUserOffers(string.Format(Snoopi.web.Localization.PushStrings.GetText("PushOfferText"), offerCollection.Count), (Int64)item.AppUserId, item.BidId);
                //                    }
                //                    else if (item.TempAppUserId != null && item.TempAppUserId != 0)
                //                    {
                //                        Notification.SendNotificationTempUserOffers(string.Format(Snoopi.web.Localization.PushStrings.GetText("PushOfferText"), offerCollection.Count), (Int64)item.TempAppUserId, item.BidId);
                //                    }
                //                }
                //                else
                //                {
                //                    if (item.AppUserId != null && item.AppUserId != 0)
                //                    {
                //                        Notification.SendNotificationAppUserOffers(Snoopi.web.Localization.PushStrings.GetText("NoPushOfferText"), (Int64)item.AppUserId, item.BidId);
                //                        AppUserUI user = AppUserUI.GetAppUserUI((Int64)item.AppUserId);
                //                        List<BidProductUI> products = BidController.GetProductsByBid(item.BidId);
                //                        Bid b = Bid.FetchByID(item.BidId);
                //                        string subject = GlobalStrings.GetText("MailToAdmin", new CultureInfo("he-IL"));
                //                        string body = GlobalStrings.GetText("SubjectMailToAdminOffers",new CultureInfo("he-IL"));
                //                        EmailMessagingService.SendMailNoOffersToAdmin(user, b.StartDate, products, subject, body);
                //                    }
                //                    else if (item.TempAppUserId != null && item.TempAppUserId != 0)
                //                    {
                //                        Notification.SendNotificationTempUserOffers(Snoopi.web.Localization.PushStrings.GetText("NoPushOfferText"), (Int64)item.TempAppUserId, item.BidId);
                //                    }

                //                }
                //                item.IsSendOffer = true;
                //                item.Save();

                //            }
                //            jsonWriter.WritePropertyName(@"success");
                //            jsonWriter.WriteValue(true);
                //        }
                //        catch (System.Exception ex)
                //        {
                //            //RespondError(Response, HttpStatusCode.BadRequest, ex.ToString());
                //            jsonWriter.WritePropertyName(@"error");
                //            jsonWriter.WriteValue(@"unknown");
                //            jsonWriter.WritePropertyName(@"description");
                //            jsonWriter.WriteValue(ex.ToString());
                //        }
                //        jsonWriter.WriteEndObject();
                //    }
                //}
            }
            else if (PathParams[0] == @"service_offer")
            {
                using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
                {
                    using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                    {
                        jsonWriter.WriteStartObject();
                        try
                        {
                            Query qry = new Query(BidService.TableSchema);
                            qry.Where(BidService.Columns.IsSendOffer, WhereComparision.EqualsTo, false);
                            qry.AddWhere(BidService.Columns.EndDate, WhereComparision.LessThan, DateTime.UtcNow);

                            BidServiceCollection bidCollection = BidServiceCollection.FetchByQuery(qry);
                            jsonWriter.WritePropertyName(@"qry");
                            jsonWriter.WriteValue(qry.ToString());

                            Query.New <BidService>().Where(BidService.Columns.IsSendOffer, WhereComparision.EqualsTo, false)
                            .AddWhere(BidService.Columns.EndDate, WhereComparision.LessThan, DateTime.UtcNow)
                            .Update(BidService.Columns.IsSendOffer, true)
                            .Execute();

                            foreach (BidService item in bidCollection)
                            {
                                Query q = new Query(OfferService.TableSchema);
                                q.Where(OfferService.Columns.BidId, WhereComparision.EqualsTo, item.BidId);

                                OfferServiceCollection offerCollection = OfferServiceCollection.FetchByQuery(q);
                                if (offerCollection != null && offerCollection.Count > 0)
                                {
                                    if (item.AppUserId != null && item.AppUserId != 0)
                                    {
                                        Notification.SendNotificationAppUserOffers(string.Format(Snoopi.web.Localization.PushStrings.GetText("PushOfferText"), offerCollection.Count), (Int64)item.AppUserId, item.BidId, true);
                                    }
                                    else if (item.TempAppUserId != null && item.TempAppUserId != 0)
                                    {
                                        Notification.SendNotificationTempUserOffers(string.Format(Snoopi.web.Localization.PushStrings.GetText("PushOfferText"), offerCollection.Count), (Int64)item.TempAppUserId, item.BidId, true);
                                    }
                                }
                                else
                                {
                                    if (item.AppUserId != null && item.AppUserId != 0)
                                    {
                                        Notification.SendNotificationAppUserOffers(Snoopi.web.Localization.PushStrings.GetText("NoPushOfferText"), (Int64)item.AppUserId, item.BidId, true);
                                        AppUserUI           user     = AppUserUI.GetAppUserUI((Int64)item.AppUserId);
                                        List <BidProductUI> products = BidController.GetProductsByBid(item.BidId);
                                        Bid    b       = Bid.FetchByID(item.BidId);
                                        string subject = GlobalStrings.GetText("MailToAdmin");
                                        string body    = GlobalStrings.GetText("SubjectMailToAdminOffers");
                                        EmailMessagingService.SendMailNoOffersToAdmin(user, b.StartDate, products, subject, body);
                                    }
                                    else if (item.TempAppUserId != null && item.TempAppUserId != 0)
                                    {
                                        Notification.SendNotificationTempUserOffers(Snoopi.web.Localization.PushStrings.GetText("NoPushOfferText"), (Int64)item.TempAppUserId, item.BidId, true);
                                    }
                                }
                                item.IsSendOffer = true;
                                item.Save();
                            }
                            jsonWriter.WritePropertyName(@"success");
                            jsonWriter.WriteValue(true);
                        }
                        catch (System.Exception ex)
                        {
                            //RespondError(Response, HttpStatusCode.BadRequest, ex.ToString());
                            jsonWriter.WritePropertyName(@"error");
                            jsonWriter.WriteValue(@"unknown");
                            jsonWriter.WritePropertyName(@"description");
                            jsonWriter.WriteValue(ex.ToString());
                        }
                        jsonWriter.WriteEndObject();
                    }
                }
            }
            else if (PathParams[0] == @"order_received")
            {
                using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
                {
                    using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                    {
                        jsonWriter.WriteStartObject();
                        try
                        {
                            Query qry = new Query(Order.TableSchema);
                            qry.Where(Order.Columns.IsSendRecived, WhereComparision.EqualsTo, false);
                            qry.AddWhere(Order.Columns.ReceivedDate, WhereComparision.EqualsTo, null);
                            qry.AddWhere(Order.Columns.UserPaySupplierStatus, WhereComparision.EqualsTo, UserPaymentStatus.Payed);
                            qry.AddWhere(Order.Columns.SuppliedDate, WhereComparision.LessThanOrEqual, DateTime.UtcNow.AddHours(-24));

                            OrderCollection orderCollection = OrderCollection.FetchByQuery(qry);

                            //Query.New<Order>().Where(Order.Columns.IsSendRecived, WhereComparision.EqualsTo, false)
                            //     .AddWhere(Order.Columns.ReceivedDate, WhereComparision.EqualsTo, null)
                            //     .AddWhere(Order.Columns.CreateDate, WhereComparision.LessThanOrEqual, DateTime.UtcNow.AddHours(-24))
                            //     .Update(Order.Columns.IsSendRecived, true)
                            //     .Execute();

                            foreach (Order item in orderCollection)
                            {
                                Notification.SendNotificationAppUserReceviedOrder(Snoopi.web.Localization.PushStrings.GetText("ReceivedOrder"), (Int64)item.AppUserId, item.OrderId);
                                item.IsSendRecived = true;
                                item.Save();
                            }

                            jsonWriter.WritePropertyName(@"success");
                            jsonWriter.WriteValue(true);
                        }
                        catch (System.Exception ex)
                        {
                            //RespondError(Response, HttpStatusCode.BadRequest, ex.ToString());
                            jsonWriter.WritePropertyName(@"error");
                            jsonWriter.WriteValue(@"unknown");
                            jsonWriter.WritePropertyName(@"description");
                            jsonWriter.WriteValue(ex.ToString());
                        }
                        jsonWriter.WriteEndObject();
                    }
                }
            }
            else if (PathParams[0] == @"auto_push")
            {
                using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
                {
                    using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                    {
                        jsonWriter.WriteStartObject();
                        try
                        {
                            var filters = NotificationGroups.GetAutoFilters();
                            foreach (var item in filters)
                            {
                                if (item.LastRun == null || item.LastRun.Value.AddDays(1) < DateTime.Now)
                                {
                                    var users = NotificationGroups.GetUsersOfAutoFilter(item);
                                    try
                                    {
                                        Task.Run(() => Snoopi.core.FcmService.SendTemplateToMany(item.Name, item.MessageTemplate, users)).Wait();
                                    }
                                    catch (Exception ex)
                                    {
                                        using (System.IO.StreamWriter sw = System.IO.File.AppendText(AppDomain.CurrentDomain.BaseDirectory + @"\Output\push-log.txt"))
                                        {
                                            sw.WriteLine(@" ------------" + DateTime.Now + "--------------------" + '\n' + "Exception  " + ex.Message + " CallStack : " + ex.StackTrace);
                                        }
                                    }
                                    item.LastRun = DateTime.Now;
                                    item.Save();
                                }
                            }

                            jsonWriter.WritePropertyName(@"success");
                            jsonWriter.WriteValue(true);
                        }
                        catch (System.Exception ex)
                        {
                            //RespondError(Response, HttpStatusCode.BadRequest, ex.ToString());
                            jsonWriter.WritePropertyName(@"error");
                            jsonWriter.WriteValue(@"unknown");
                            jsonWriter.WritePropertyName(@"description");
                            jsonWriter.WriteValue(ex.ToString());
                        }
                        jsonWriter.WriteEndObject();
                    }
                }
            }
            else if (PathParams[0] == @"rate_supplier")
            {
                using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
                {
                    using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                    {
                        jsonWriter.WriteStartObject();
                        try
                        {
                            Query qry = new Query(Order.TableSchema);
                            qry.Where(Order.Columns.IsSendRateSupplier, WhereComparision.EqualsTo, false);
                            qry.AddWhere(Order.Columns.SuppliedDate, WhereComparision.LessThanOrEqual, DateTime.UtcNow.AddHours(-Settings.GetSettingInt32(Settings.Keys.RATE_SUPPLIER_AFTER_ORDER_HOUR, 24)));

                            OrderCollection orderCollection = OrderCollection.FetchByQuery(qry);

                            Query.New <Order>().Where(Order.Columns.IsSendRateSupplier, WhereComparision.EqualsTo, false)
                            .AddWhere(Order.Columns.SuppliedDate, WhereComparision.LessThanOrEqual, DateTime.UtcNow.AddHours(-Settings.GetSettingInt32(Settings.Keys.RATE_SUPPLIER_AFTER_ORDER_HOUR, 24)))
                            .Update(Order.Columns.IsSendRateSupplier, true)
                            .Execute();

                            foreach (Order item in orderCollection)
                            {
                                var         bid      = Bid.FetchByID(item.BidId);
                                AppSupplier supplier = AppSupplier.FetchByID(item.SupplierId);
                                Notification.SendNotificationAppUserRateSupplier(Snoopi.web.Localization.PushStrings.GetText("RateSupplier"), item.AppUserId, item.SupplierId.Value, supplier.BusinessName, item.BidId);
                                item.IsSendRateSupplier = true;
                                item.Save();
                            }

                            jsonWriter.WritePropertyName(@"success");
                            jsonWriter.WriteValue(true);
                        }
                        catch (System.Exception ex)
                        {
                            //RespondError(Response, HttpStatusCode.BadRequest, ex.ToString());
                            jsonWriter.WritePropertyName(@"error");
                            jsonWriter.WriteValue(@"unknown");
                            jsonWriter.WritePropertyName(@"description");
                            jsonWriter.WriteValue(ex.ToString());
                        }
                        jsonWriter.WriteEndObject();
                    }
                }
            }
            else if (PathParams[0] == @"test_rate_supplier")
            {
                Notification.SendNotificationAppUserRateSupplier(Snoopi.web.Localization.PushStrings.GetText("RateSupplier"), 18283, 387, "PetBool", 2345);
            }
            else
            {
                using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
                {
                    using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                    {
                        jsonWriter.WriteStartObject();
                        jsonWriter.WritePropertyName(@"error");
                        jsonWriter.WriteValue(@"unknown");
                        jsonWriter.WriteEndObject();
                    }
                }
            }
        }
Пример #27
0
        public bool InsertBid(BidData bidData)
        {
            BidController bCtr = new BidController();

            return(bCtr.InsertBid(bidData));
        }
Пример #28
0
        public List <BidData> GetBids(int id)
        {
            BidController bCtr = new BidController();

            return(bCtr.GetBids(id));
        }
Пример #29
0
        public double GetMaxBidOnAuction(int auctionId)
        {
            BidController bCtr = new BidController();

            return(bCtr.GetMaxBidOnAuction(auctionId));
        }
Пример #30
0
        public static List <OrderUI> GetAllAppUserOrders(Int64 AppUserId = 0, DateTime from = new DateTime(), DateTime to = new DateTime(), string SearchBid = "", int PageSize = 0, int CurrentPageIndex = 0)
        {
            Query q = new Query(Order.TableSchema);

            q.Join(JoinType.InnerJoin, Order.TableSchema, Order.Columns.BidId, Order.TableSchema.SchemaName,
                   Bid.TableSchema, Bid.Columns.BidId, Bid.TableSchema.SchemaName);
            q.Join(JoinType.LeftJoin, Order.TableSchema, Order.Columns.DonationId, Order.TableSchema.SchemaName,
                   Donation.TableSchema, Donation.Columns.DonationId, Donation.TableSchema.SchemaName);
            q.Join(JoinType.InnerJoin, Order.TableSchema, Order.Columns.SupplierId, Order.TableSchema.SchemaName,
                   AppSupplier.TableSchema, AppSupplier.Columns.SupplierId, AppSupplier.TableSchema.SchemaName);
            q.Join(JoinType.LeftJoin, Order.TableSchema, Order.Columns.CampaignId, Order.TableSchema.SchemaName,
                   Campaign.TableSchema, Campaign.Columns.CampaignId, Campaign.TableSchema.SchemaName);

            q.OrderBy(Order.TableSchema.SchemaName, Order.Columns.CreateDate, SortDirection.DESC);
            q.Select(Order.TableSchema.SchemaName, Order.Columns.OrderId, Order.Columns.OrderId, true);
            q.AddSelect(AppSupplier.TableSchema.SchemaName, AppSupplier.Columns.BusinessName, AppSupplier.Columns.BusinessName);
            q.AddSelect(AppSupplier.TableSchema.SchemaName, AppSupplier.Columns.SupplierId, AppSupplier.Columns.SupplierId);
            q.AddSelect(AppSupplier.TableSchema.SchemaName, AppSupplier.Columns.Precent, AppSupplier.Columns.Precent);
            q.AddSelect(Order.TableSchema.SchemaName, Order.Columns.CreateDate, Order.Columns.CreateDate);
            q.AddSelect(Bid.TableSchema.SchemaName, Bid.Columns.BidId, Bid.Columns.BidId);
            q.AddSelect(Bid.TableSchema.SchemaName, Bid.Columns.StartDate, Bid.Columns.StartDate);
            q.AddSelect(Bid.TableSchema.SchemaName, Bid.Columns.EndDate, Bid.Columns.EndDate);
            q.AddSelect(Donation.TableSchema.SchemaName, Donation.Columns.DonationPrice, Donation.Columns.DonationPrice);
            q.AddSelect(Order.TableSchema.SchemaName, Order.Columns.TotalPrice, Order.Columns.TotalPrice);
            q.AddSelect(Order.TableSchema.SchemaName, Order.Columns.Gifts, Order.Columns.Gifts);
            q.AddSelect(Order.TableSchema.SchemaName, Order.Columns.TotalPrice, Order.Columns.TotalPrice);
            q.AddSelect(Order.TableSchema.SchemaName, Order.Columns.PriceAfterDiscount, Order.Columns.PriceAfterDiscount);
            q.AddSelect(Order.TableSchema.SchemaName, Order.Columns.PrecentDiscount, Order.Columns.PrecentDiscount);
            q.AddSelect(Order.TableSchema.SchemaName, Order.Columns.IsSendRecived, Order.Columns.IsSendRecived);
            //q.AddSelect(Order.TableSchema.SchemaName, Order.Columns.TransactionResponseCode, Order.Columns.TransactionResponseCode);
            //q.AddSelect(Order.TableSchema.SchemaName, Order.Columns.TransactionStatus, Order.Columns.TransactionStatus);
            q.AddSelect(Campaign.TableSchema.SchemaName, Campaign.Columns.CampaignName, Campaign.Columns.CampaignName);
            q.Where(Order.TableSchema.SchemaName, Order.Columns.AppUserId, WhereComparision.EqualsTo, AppUserId);
            q.AddWhere(Order.TableSchema.SchemaName, Order.Columns.UserPaySupplierStatus, WhereComparision.EqualsTo, UserPaymentStatus.Payed);
            if (from != DateTime.MinValue)
            {
                q.AddWhere(Order.TableSchema.SchemaName, Order.Columns.CreateDate, WhereComparision.GreaterThanOrEqual, from);
            }
            if (to != DateTime.MinValue)
            {
                q.AddWhere(Order.TableSchema.SchemaName, Order.Columns.CreateDate, WhereComparision.LessThanOrEqual, to);
            }
            if (SearchBid != "")
            {
                q.AddWhere(Order.TableSchema.SchemaName, Order.Columns.BidId, WhereComparision.Like, SearchBid);
            }
            if (PageSize > 0)
            {
                q.LimitRows(PageSize).OffsetRows(PageSize * CurrentPageIndex);
            }

            List <OrderUI> LstOrder = new List <OrderUI>();

            using (DataReaderBase reader = q.ExecuteReader())
            {
                while (reader.Read())
                {
                    OrderUI orderUI = new OrderUI();
                    orderUI.SupplierName       = (reader[AppSupplier.Columns.BusinessName] != null ? reader[AppSupplier.Columns.BusinessName].ToString() : "");
                    orderUI.SupplierId         = (reader[AppSupplier.Columns.SupplierId] != null ? Int64.Parse(reader[AppSupplier.Columns.SupplierId].ToString()) : 0);
                    orderUI.OrderId            = (reader[Order.Columns.OrderId] != null ? Int64.Parse(reader[Order.Columns.OrderId].ToString()) : 0);
                    orderUI.OrderDate          = (reader[Order.Columns.CreateDate] != null ? DateTime.Parse(reader[Order.Columns.CreateDate].ToString()).ToLocalTime() : DateTime.MinValue);
                    orderUI.BidId              = (reader[Bid.Columns.BidId] != null ? Int64.Parse(reader[Bid.Columns.BidId].ToString()) : 0);
                    orderUI.BidEndDate         = (reader[Bid.Columns.EndDate] != null ? DateTime.Parse(reader[Bid.Columns.EndDate].ToString()).ToLocalTime() : DateTime.MinValue);
                    orderUI.DonationPrice      = ((reader[Donation.Columns.DonationPrice] is DBNull) ? 0 : Convert.ToDecimal(reader[Donation.Columns.DonationPrice]));
                    orderUI.TotalPrice         = (reader[Order.Columns.TotalPrice] != null ? decimal.Parse(reader[Order.Columns.TotalPrice].ToString()) : 0);
                    orderUI.PriceAfterDiscount = (reader[Order.Columns.PriceAfterDiscount] != null ? decimal.Parse(reader[Order.Columns.PriceAfterDiscount].ToString()) : 0);
                    orderUI.Precent            = (reader[AppSupplier.Columns.Precent] != null ? Int32.Parse(reader[AppSupplier.Columns.Precent].ToString()) : 0);
                    orderUI.PaymentForSupplier = orderUI.TotalPrice * ((100m - orderUI.Precent) / 100);
                    orderUI.PrecentDiscount    = (reader[Order.Columns.PrecentDiscount] != null ? Int32.Parse(reader[Order.Columns.PrecentDiscount].ToString()) : 0);
                    orderUI.IsSendReceived     = (reader[Order.Columns.IsSendRecived] != null) ? Convert.ToBoolean(reader[Order.Columns.IsSendRecived]) : false;
                    // orderUI.TransactionResponseCode = (reader[Order.Columns.TransactionResponseCode] != null ? reader[Order.Columns.TransactionResponseCode].ToString() : "");
                    // orderUI.TransactionStatus = (OrderStatus)Enum.Parse(typeof(OrderStatus), reader[Order.Columns.TransactionStatus].ToString());
                    orderUI.Gift         = (reader[Order.Columns.Gifts] != null ? reader[Order.Columns.Gifts].ToString() : "");
                    orderUI.CampaignName = (reader[Campaign.Columns.CampaignName] != null ? reader[Campaign.Columns.CampaignName].ToString() : "");
                    orderUI.LstProduct   = BidController.GetProductsByBid(orderUI.BidId);
                    LstOrder.Add(orderUI);
                }
            }
            return(LstOrder);
        }