示例#1
0
        public ActionResult AuctionOrder()
        {
            var auctionOrderModel = new AuctionOrderModel();

            // Default settings
            auctionOrderModel.Count         = "0";
            auctionOrderModel.Price         = "0";
            auctionOrderModel.Amount        = "0";
            auctionOrderModel.MinimalSum    = "0";
            auctionOrderModel.Step          = "1";
            auctionOrderModel.TradeWarranty = "1";
            auctionOrderModel.Percent       = "0";
            auctionOrderModel.DeliveryTerm  = "DDP";
            auctionOrderModel.DeliveryPlace = "г. Семей, ул. Би Боронбай, 93";
            auctionOrderModel.DeliveryTime  = "Согласно договору";
            auctionOrderModel.Payment       = "По факту";

            try {
                auctionOrderModel.units = DataBaseClient.GetUnits();
                LogService.LogInfo("AuctionOrder page opened");
            } catch (Exception ex) {
                LogService.LogInfo("AuctionOrder page opened with error: " + ex);
                return(null);
            }

            return(View(auctionOrderModel));
        }
示例#2
0
        public ActionResult AuctionOrder(AuctionOrderModel auctionOrderModel)
        {
            if (ModelState.IsValid)
            {
                Order order = new Order();

                order.Date = DateTime.Now;
                order.Auction.Lots.Add(new Lot {
                    Name          = auctionOrderModel.LotName,
                    Quantity      = Convert.ToDecimal(auctionOrderModel.Count.Replace(".", ",")),
                    UnitId        = auctionOrderModel.UnitId,
                    Price         = Convert.ToDecimal(auctionOrderModel.Price.Replace(".", ",")),
                    Sum           = Convert.ToDecimal(auctionOrderModel.Amount.Replace(".", ",")),
                    Step          = Convert.ToDecimal(auctionOrderModel.Step.Replace(".", ",")),
                    Warranty      = Convert.ToDecimal(auctionOrderModel.TradeWarranty.Replace(".", ",")),
                    LocalContent  = Convert.ToInt32(auctionOrderModel.Percent),
                    DeliveryPlace = auctionOrderModel.DeliveryPlace + "|" + auctionOrderModel.DeliveryTerm,
                    DeliveryTime  = auctionOrderModel.DeliveryTime,
                    PaymentTerm   = auctionOrderModel.Payment
                });

                try {
                    order.Auction.OwnerId = DataBaseClient.GetUserByLogin(HttpContext.User.Identity.Name).Id;
                } catch (Exception) { order.Auction.OwnerId = 1; }

                order.Auction.Comments = auctionOrderModel.MinimalSum + "|" + auctionOrderModel.Comments;

                var statusModel = new StatusModel();

                try {
                    DataBaseClient.SetNewKarazhiraOrder(order);
                    statusModel.Status = 1;
                    EmailSender.Send("*****@*****.**", "ablrzaieneayisqa", "*****@*****.**", "Новая заявка Каражыры от " + DateTime.Now.ToShortDateString() + " по лоту " + order.Auction.Lots[0].Name, "Не забудьте обработать!");
                    LogService.LogInfo("Order created successfuly");
                } catch (Exception ex) {
                    statusModel.Status = 0;
                    LogService.LogInfo("Order created with error: " + ex);
                }

                return(View("CreateStatus", statusModel));
            }
            else
            {
                try {
                    auctionOrderModel.units = DataBaseClient.GetUnits();
                    LogService.LogInfo("AuctionOrder page re-opened because validation summary error");
                } catch (Exception ex) {
                    LogService.LogInfo("AuctionOrder page re-opened with error: " + ex);
                    return(null);
                }

                return(View(auctionOrderModel));
            }
        }