示例#1
0
        public ActionResult AjaxBuy(int?id)
        {
            Dictionary <string, int> d = new Dictionary <string, int>();

            if (id == null)
            {
                d.Add("ret", -1);
                return(Json(d));
            }
            UserModels userModels = new UserModels();

            if (Session["userid"] != null)
            {
                userModels         = db.User.Find(Session["userid"]);
                ViewBag.userModels = userModels;
            }
            else
            {
                d.Add("ret", -2);
                return(Json(d));
            }
            OrderModels         om = db.Order.Find(id);
            HousePropertyModels hm = om.houseProperty;

            om.status = 3;
            db.Order.Attach(om);
            db.Entry(om).Property(m => m.status).IsModified = true;
            db.HousePropertyModels.Attach(hm);
            db.SaveChanges();
            d.Add("ret", 1);
            return(Json(d));
        }
示例#2
0
        // GET: Orders/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OrderModels orderModels = db.OrderModels.Find(id);

            if (orderModels == null)
            {
                return(HttpNotFound());
            }

            string user_name = User.Identity.GetUserName();

            if (orderModels.Email != user_name)
            {
                return(HttpNotFound());
            }

            var resultProductsJoin = db.ProductOrderModels.Where(s => s.CartId == orderModels.Id).ToList();

            var resultProducts = db.ProductsModels.Join(db.ProductOrderModels, s => s.Id, sa => sa.ProductId, (s, sa) => new { products = s, productsJoin = sa }).Where(b => b.productsJoin.CartId == orderModels.Id).Select(ssa => ssa.products);

            var model = new OrderViewModels()
            {
                Order = orderModels,

                ProductsJoin = resultProductsJoin,

                Products = resultProducts
            };

            return(View(model));
        }
示例#3
0
        public ActionResult OrderAdd(OrderModels model)
        {
            ViewBag.RegisterSucess = "";
            if (ModelState.IsValid)
            {
                try
                {
                    context.OrderSet.Add(new Order()
                    {
                        Manager   = context.ManagerSet.First(x => x.LastName == model.Manager),
                        Client    = context.ClientSet.First(x => x.LastName == model.Client),
                        ManagerId = context.ManagerSet.First(x => x.LastName == model.Manager).Id,
                        ClientId  = context.ClientSet.First(x => x.LastName == model.Client).Id,
                        Amount    = model.Amount,
                        Item      = context.ItemSet.First(x => x.Name == model.Item),
                        ItemId    = context.ItemSet.First(x => x.Name == model.Item).Id,
                        ItemCount = model.Count,
                        OrderTime = DateTime.Now
                    });
                    context.SaveChanges();
                    ViewBag.RegisterSucess = "Заказ  оформлен";
                    return(View());
                }
                catch (MembershipCreateUserException e)
                {
                    //ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            return(View(model));
        }
示例#4
0
        public OrderModels CreateOrder(OrderModels newOrder, string user_id)
        {
            var cart = GetCart();

            newOrder.Order_ordered_at = DateTime.Now;
            newOrder.Order_User_id    = user_id;

            db.Orders.Add(newOrder);

            if (newOrder.OrderPosition == null)
            {
                newOrder.OrderPosition = new List <OrderPositionModels>();
            }

            double cartValue = 0;

            foreach (var cartElem in cart)
            {
                var newOrderPosition = new OrderPositionModels()
                {
                    OrderPosition_product_id = cartElem.Product.Id,
                    OrderPosition_quantity   = cartElem.quantity,
                    OrderPosition_price      = cartElem.Product.Product_price
                };

                cartValue += (cartElem.quantity * cartElem.Product.Product_price);
                newOrder.OrderPosition.Add(newOrderPosition);
            }

            newOrder.Order_total_order_price = cartValue;
            db.SaveChanges();

            return(newOrder);
        }
        public async Task <IActionResult> Post([FromBody] OrderModels model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var newOrder = _mapper.Map <OrderModels, Order>(model);

                    if (newOrder.OrderDate == DateTime.MinValue)
                    {
                        newOrder.OrderDate = DateTime.Now;
                    }

                    var currentUser = await _userManager.FindByNameAsync(User.Identity.Name);

                    newOrder.Users = currentUser;

                    _repo.addEntity(newOrder);
                    if (_repo.Save())
                    {
                        return(Created($"api/order/{newOrder.Id}", _mapper.Map <Order, OrderModels>(newOrder)));
                        //return Ok(model);
                    }
                }
                else
                {
                    return(BadRequest(ModelState));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Can not save the order{ex}");
            }
            return(BadRequest("Can not save the order"));
        }
        public ActionResult GenerarPDF(string idSesion = "")
        {
            try
            {
                LocalReport lr = new LocalReport();
                List <ProductOrderModels> lobeProdsPedido = (List <ProductOrderModels>)Session["lobeProdsPedido"];
                OrderModels order;
                order = (OrderModels)Session["orderModels"];
                if (order == null)
                {
                    order = new OrderModels();
                    order.lobeProducto = lobeProdsPedido;
                }

                List <OrderModels> lobeOrder = new List <OrderModels>();
                lobeOrder.Add(order);

                string rutaRep = ConfigurationManager.AppSettings["RutaReporteSolicitud"].ToString();
                lr.EnableExternalImages = true;
                lr.ReportPath           = rutaRep;

                lr.DataSources.Add(new ReportDataSource("DataSet1", lobeOrder));
                lr.DataSources.Add(new ReportDataSource("DataSet2", lobeProdsPedido));

                string reportType;
                string format = "PDF";
                if (format == null || format == "" || format == "jpeg")
                {
                    reportType = "Image";
                    format     = "jpeg";
                }
                else
                {
                    reportType = format;
                }
                string mimeType;
                string encoding;
                string fileNameExtension;
                //string deviceInfo;
                string deviceInfo = "<DeviceInfo>" +
                                    "   <OutputFormat>" + format + "</OutputFormat>" +
                                    "  <PageWidth>9in</PageWidth>" +
                                    "  <PageHeight>12in</PageHeight>" +
                                    //"  <MarginTop>0.5in</MarginTop>" +
                                    "  <MarginLeft>0.75in</MarginLeft>" +
                                    //"  <MarginRight>1in</MarginRight>" +
                                    //"  <MarginBottom>0.5in</MarginBottom>" +
                                    "</DeviceInfo>";
                Warning[] warnings      = null;
                string[]  streams       = null;
                byte[]    renderedBytes = null;

                renderedBytes = lr.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
                return(File(renderedBytes, mimeType));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("VerPedido", "ProductModels", new { idSesion = "" }));
            }
        }
 public ActionResult GenerarReciboFicticioOPedido(string IdCliente       = "", string NombreCliente = "", string Direccion        = "",
                                                  string FechaDiaEntrega = "", string HoraEntrega   = "", string DescripcionVenta = "", decimal PrecioTotalVenta = 0,
                                                  string EsPedido        = "", string EsCotizacion  = "")
 {
     try
     {
         if (EsCotizacion == "on")
         {
             return(null);
         }
         else if (EsPedido == "on")
         {
             OrderModels oOrder = new OrderModels()
             {
                 IdCliente       = IdCliente,
                 NombreCliente   = NombreCliente,
                 Direccion       = Direccion,
                 FechaDiaEntrega = FechaDiaEntrega,
                 HoraEntrega     = HoraEntrega
             };
             return(GenerarPedido(oOrder));
         }
         else
         {
             return(GenerarPDFReciboFicticio(IdCliente, NombreCliente, Direccion, FechaDiaEntrega,
                                             HoraEntrega, DescripcionVenta, PrecioTotalVenta));
         }
     }
     catch (Exception ex)
     {
         return(RedirectToAction("VerPedido", "ProductModels", new { idSesion = "" }));
     }
 }
示例#8
0
        public ActionResult Finish(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserModels userModels = new UserModels();

            if (Session["userid"] != null)
            {
                userModels         = db.User.Find(Session["userid"]);
                ViewBag.userModels = userModels;
            }
            else
            {
                return(RedirectToAction("Login"));
            }
            OrderModels         om = db.Order.Find(id);
            HousePropertyModels hm = om.houseProperty;

            om.status     = 1;
            om.finishTime = DateTime.Now;
            db.Order.Attach(om);
            db.Entry(om).Property(m => m.status).IsModified     = true;
            db.Entry(om).Property(m => m.finishTime).IsModified = true;
            hm.status = 1;
            db.HousePropertyModels.Attach(hm);
            db.Entry(hm).Property(m => m.status).IsModified = true;
            db.Database.ExecuteSqlCommand("update HousePropertyModels set owner_id=" + om.buyer.id + " where id=" + hm.id);
            db.SaveChanges();
            return(RedirectToAction("userSell"));
        }
示例#9
0
        public ActionResult DeleteFromOrder(int id, int OredrId)
        {
            OrderModels orderModels = db.OrderModels.Find(OredrId);

            if (orderModels != null)
            {
                var product       = db.ProductsModels.Find(id);
                var productToCart = db.ProductOrderModels.Where(s => s.CartId == orderModels.Id).Where(b => b.ProductId == product.Id).FirstOrDefault();

                productToCart.CartId    = orderModels.Id;
                productToCart.ProductId = product.Id;

                orderModels.TotalAmount      = orderModels.TotalAmount - product.CurrentPrice;
                orderModels.NumberOfProducts = orderModels.NumberOfProducts - 1;

                db.ProductOrderModels.Remove(productToCart);
                db.SaveChanges();

                product.Stock = product.Stock + 1;
                db.SaveChanges();
            }

            string redirectUrl = "/Orders/Details/" + OredrId;

            return(Redirect(redirectUrl));
        }
        public void Post([FromBody] OrderModels order)
        {
            order.Date = DateTime.UtcNow.ToString();
            var json = new JavaScriptSerializer().Serialize(order);

            string       subject      = "NewOrder";
            string       body         = json.ToString();
            const string fromPassword = "******";
            string       fromAddress  = "*****@*****.**";
            string       toAddress    = " [email protected]";

            var smtp = new SmtpClient
            {
                Host           = "smtp.gmail.com",
                Port           = 587,
                EnableSsl      = true,
                DeliveryMethod = SmtpDeliveryMethod.Network,
                Credentials    = new NetworkCredential(fromAddress, fromPassword),
                Timeout        = 20000
            };

            using (var message = new MailMessage(fromAddress, toAddress)
            {
                Subject = subject,
                Body = body
            })
            {
                smtp.Send(message);
            }
        }
示例#11
0
 // POST: /orders/new
 public IActionResult New(OrderModels model)
 {
     model.Products     = _context.Products.OrderBy(p => p.ProductName).ToList();
     model.Customers    = _context.Customers.OrderBy(c => c.CustomerName).ToList();
     model.Transactions = _context.Orders.Include(o => o.Customer).Include(o => o.Product).ToList();
     if (ModelState.IsValid)
     {
         Product item = _context.Products.Where(p => p.ID == model.Orders.ProductID).SingleOrDefault();
         if (model.Orders.OrderQuantity >= item.ProductQuantity)
         {
             ModelState.AddModelError("OrderQuanity", $"Quantity exceeds inventory. {item.ProductQuantity} remain in stock.");
         }
         else
         {
             Order newOrder = new Order
             {
                 CustomerID    = model.Orders.CustomerID,
                 ProductID     = model.Orders.ProductID,
                 OrderQuantity = model.Orders.OrderQuantity
             };
             item.ProductQuantity -= model.Orders.OrderQuantity;
             _context.Add(newOrder);
             _context.SaveChanges();
             return(RedirectToAction("Index", model));
         }
     }
     return(View("Index", model));
 }
示例#12
0
        public async Task <ActionResult> Pay(OrderModels orderDetails)
        {
            if (ModelState.IsValid)
            {
                var userId   = User.Identity.GetUserId();
                var newOrder = cartManager.CreateOrder(orderDetails, userId);
                var user     = await UserManager.FindByIdAsync(userId);

                var userOwnTable = db.Users.Where(x => x.Account_email == user.Email).SingleOrDefault();
                userOwnTable.AccountData.City = orderDetails.Order_city;
                if (TryUpdateModel(userOwnTable))
                {
                    db.SaveChanges();
                }

                await UserManager.UpdateAsync(user);

                cartManager.EmptyCart();

                //maileService.WyslaniePotwierdzenieZamowieniaEmail(newOrder);

                return(RedirectToAction("OrderConfirmation"));
            }
            else
            {
                return(View(orderDetails));
            }
        }
示例#13
0
        public ActionResult DeleteConfirmed(int id)
        {
            OrderModels orderModels = db.Orders.Find(id);

            db.Orders.Remove(orderModels);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#14
0
        public ActionResult order(bool?Pay)
        {
            ViewData["MyYiku"] = "order";


            OrderModels om = new OrderModels();

            return(View(om));
        }
示例#15
0
        public OrderStatus ChangeOrderStatus(OrderModels order)
        {
            OrderModels order_to_modification = db.Orders.Find(order.Id);

            order_to_modification.Order_order_status = order.Order_order_status;
            db.SaveChanges();

            return(order.Order_order_status);
        }
示例#16
0
 public ActionResult Edit([Bind(Include = "ID,ID_User")] OrderModels orderModels)
 {
     if (ModelState.IsValid)
     {
         db.Entry(orderModels).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(orderModels));
 }
示例#17
0
 public ActionResult Edit([Bind(Include = "Id,orderClient,orderType,orderCategory,orderVariety,orderQuantity,orderDollars,orderDate,orderComment,orderStatus")] OrderModels orderModels)
 {
     if (ModelState.IsValid)
     {
         db.Entry(orderModels).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(orderModels));
 }
示例#18
0
 public ActionResult Edit([Bind(Include = "Id,AccountId,Email,TotalAmount,NumberOfProducts,Name,Phone,Address,City,State,Status")] OrderModels orderModels)
 {
     if (ModelState.IsValid)
     {
         db.Entry(orderModels).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(orderModels));
 }
示例#19
0
        public ActionResult Create([Bind(Include = "Id,orderCreateDate,orderClient,orderType,orderCategory,orderVariety,orderQuantity,orderDollars,orderDueDate,orderComment,orderStatus")] OrderModels orderModels)
        {
            if (ModelState.IsValid)
            {
                db.orderData.Add(orderModels);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(orderModels));
        }
示例#20
0
        public IActionResult Index()
        {
            OrderModels data = new OrderModels
            {
                Products     = _context.Products.OrderBy(p => p.ProductName).ToList(),
                Customers    = _context.Customers.OrderBy(c => c.CustomerName).ToList(),
                Transactions = _context.Orders.Include(o => o.Customer).Include(o => o.Product).ToList(),
                Orders       = new Order(),
            };

            return(View(data));
        }
示例#21
0
        public OrderModels GetOrderById(int id)
        {
            OrderModels orderModel = null;

            using (var context = new TakeThaiContext())
            {
                orderModel = context.OrderModels
                             .Include(o => o.SubOrderModelsList)
                             .FirstOrDefault(o => o.Id == id);
            }

            return(orderModel);
        }
示例#22
0
        // GET: Orders/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OrderModels orderModels = db.Orders.Find(id);

            if (orderModels == null)
            {
                return(HttpNotFound());
            }
            return(View(orderModels));
        }
示例#23
0
        public ActionResult Forgot_password(FormCollection collection)
        {
            OrderModels   orderModels = new OrderModels();
            WebInfoModels web_infor   = new WebInfoModels();
            UserModels    sv          = new UserModels();
            C_User        it          = new C_User();
            var           login_view  = new Login_view();

            this.TryUpdateModel(login_view);

            login_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            login_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();
            login_view.Return_url        = Url.Action("login", "dashboard", new { area = "admin" });

            ////check user_name or email
            it = sv.GetUserbyUserName(login_view.User_name);
            if (it != null)
            {
                login_view.Message = App_GlobalResources.Lang.strMessageSendNewPassword;
                string code = GetCodeUniqueKey(8); ////orderModels.getOrderCodeUnique();
                string link = Url.Action("change_password", "dashboard", new { cfcode = MD5Extend.EncodePassword(code + " " + login_view.User_name), area = "admin" });
                //// send email to client
                var strBody_email_client = GeneralModels.GetContent(CommonGlobal.EmailConfirmForgotPassword, Lang).ToString(); ////get from email template
                strBody_email_client = strBody_email_client.Replace("{domain}", Util.GetConfigValue("Domain", Request.UserHostName).ToString());
                strBody_email_client = strBody_email_client.Replace("{store_name}", GeneralModels.GetContent(CommonGlobal.PageName, Lang).ToString());
                strBody_email_client = strBody_email_client.Replace("{email}", web_infor.GetContent(CommonGlobal.Email).ToString());
                strBody_email_client = strBody_email_client.Replace("{email_client}", login_view.User_name);
                strBody_email_client = strBody_email_client.Replace("{code}", code);
                strBody_email_client = strBody_email_client.Replace("{link}", Util.GetConfigValue("Domain", Request.UserHostName).ToString() + link);
                ////send email to email system
                if (login_view.User_name == "Admin")
                {
                    CommonGlobal.SendMail(web_infor.GetContent(CommonGlobal.Email), App_GlobalResources.Lang.strSubjectConfirmForgotPassword + "- " + Util.GetConfigValue("Domain", Request.UserHostName).ToString(), strBody_email_client);
                }
                else
                {
                    CommonGlobal.SendMail(login_view.User_name, App_GlobalResources.Lang.strSubjectConfirmForgotPassword + "- " + Util.GetConfigValue("Domain", Request.UserHostName).ToString(), strBody_email_client);
                }
            }
            else
            {
                login_view.Message = App_GlobalResources.Lang.strMessageForgotPassword;
            }

            return(this.PartialView("../page/forgot_password", login_view));
        }
示例#24
0
        public bool update(OrderModels models, string id)
        {
            try
            {
                var filter = Builders <OrderModels> .Filter.Eq("_id", ObjectId.Parse(id));

                var update = Builders <OrderModels> .Update
                             .Set("Status", models.Status);

                var result = OrderCollection.UpdateOne(filter, update);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
示例#25
0
        /// <summary>
        /// Given and entity of type "OrderModels" we replace the existing data of the entity in the storage table.
        /// </summary>
        /// <param name="om">Entity that will be replaced in the table</param>
        private void UpdatePartitionsToApprove(OrderModels om)
        {
            // Retrieve the storage account from the connection string.
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("storageConnectionString"));

            // Create the table client.
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

            // Create the CloudTable object that represents the "people" table.
            CloudTable table = tableClient.GetTableReference(ConfigurationManager.AppSettings["tableStorageOrders"]);

            //Replace the older regitry with the new data
            var operation = TableOperation.Replace(om);

            // Loop through the results, displaying information about the entity.
            table.Execute(operation);
        }
示例#26
0
        public ActionResult Create(MusicModels music)
        {
            if (ModelState.IsValid)
            {
                OrderModels order = new OrderModels()
                {
                    ID_Album = null,
                    ID_Music = music,
                    ID_User  = Convert.ToInt32(User.Identity.GetUserId()),
                };
                db.Orders.Add(order);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View("~/Views/Orders/Index.cshtml"));
        }
        public ActionResult GenerarPedido(OrderModels orderModels)
        {
            List <ProductOrderModels> lobeProdsPedido = (List <ProductOrderModels>)Session["lobeProdsPedido"];

            orderModels.lobeProducto = lobeProdsPedido;
            orderModels.PrecioCosto  = orderModels.TotalPrecioCosto;
            orderModels.PrecioVenta  = orderModels.TotalPrecioVenta;
            orderModels.PrecioFinal  = orderModels.TotalPrecioVentaConDsctoFamiliar;
            decimal dIGV = 0;

            if (ConfigurationManager.AppSettings["IGV"].ToString() != null)
            {
                decimal.TryParse(ConfigurationManager.AppSettings["IGV"].ToString(), out dIGV);
            }
            orderModels.PrecioSinIGV = Math.Round(orderModels.PrecioFinal / (1 + dIGV), 2, MidpointRounding.AwayFromZero);
            orderModels.IGV          = Math.Round(orderModels.PrecioFinal - orderModels.PrecioSinIGV, 2, MidpointRounding.AwayFromZero);
            if (ModelState.IsValid)
            {
                db.OrderModels.Add(orderModels);
                db.SaveChanges();
                lobeProdsPedido = (List <ProductOrderModels>)Session["lobeProdsPedido"];
                if (lobeProdsPedido != null)
                {
                    ProductModels oProdUpd;
                    foreach (ProductOrderModels oProd in lobeProdsPedido)
                    {
                        oProdUpd = db.ProductModels.Find(oProd.IdProducto);
                        if (oProdUpd != null)
                        {
                            oProdUpd.Stock          -= oProd.cantidadPedida;
                            db.Entry(oProdUpd).State = EntityState.Modified;
                            db.SaveChanges();
                        }
                    }
                    OrderModels oNew = db.OrderModels.ToList().Last();
                    if (oNew != null)
                    {
                        orderModels.Id = oNew.Id;
                    }
                }
                Session["orderModels"] = orderModels;
                return(RedirectToAction("GenerarPDF", "ProductModels", new { idSesion = "" }));
            }
            return(RedirectToAction("VerPedido", "ProductModels", new { idSesion = "" }));
        }
示例#28
0
        virtual protected void StartOrder(string tickerSymbol, TransactionType transactionType)
        {
            if (String.IsNullOrEmpty(tickerSymbol))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.StringCannotBeNullOrEmpty, "tickerSymbol"));
            }

            IRegion region = _regionManager.Regions[RegionNames.MainRegion];

            //Make Sure OrdersView is in CollapsibleRegion
            if (region.GetView("OrdersView") == null)
            {
                var ordersPresentationModel = _container.Resolve <IOrdersPresentationModel>();
                _ordersView = ordersPresentationModel.View;
                region.Add(_ordersView, "OrdersView");
                region.Activate(_ordersView);
            }

            IRegion ordersRegion = _regionManager.Regions[ORDERS_REGION];

            var orderCompositePresentationModel = _container.Resolve <IOrderCompositePresentationModel>();

            orderCompositePresentationModel.TransactionInfo     = new TransactionInfo(tickerSymbol, transactionType);
            orderCompositePresentationModel.CloseViewRequested += delegate
            {
                OrderModels.Remove(orderCompositePresentationModel);
                commandProxy.SubmitAllOrdersCommand.UnregisterCommand(orderCompositePresentationModel.SubmitCommand);
                commandProxy.CancelAllOrdersCommand.UnregisterCommand(orderCompositePresentationModel.CancelCommand);
                commandProxy.SubmitOrderCommand.UnregisterCommand(orderCompositePresentationModel.SubmitCommand);
                commandProxy.CancelOrderCommand.UnregisterCommand(orderCompositePresentationModel.CancelCommand);
                ordersRegion.Remove(orderCompositePresentationModel.View);
            };

            ordersRegion.Add(orderCompositePresentationModel.View);
            OrderModels.Add(orderCompositePresentationModel);

            commandProxy.SubmitAllOrdersCommand.RegisterCommand(orderCompositePresentationModel.SubmitCommand);
            commandProxy.CancelAllOrdersCommand.RegisterCommand(orderCompositePresentationModel.CancelCommand);

            //The following commands are Active Aware
            commandProxy.SubmitOrderCommand.RegisterCommand(orderCompositePresentationModel.SubmitCommand);
            commandProxy.CancelOrderCommand.RegisterCommand(orderCompositePresentationModel.CancelCommand);

            ordersRegion.Activate(orderCompositePresentationModel.View);
        }
示例#29
0
 public ActionResult Detail(OrderModels orders, string id)
 {
     if (ModelState.IsValid)
     {
         var result = new OrderDao().ViewDetail(id);
         var dao    = new USERDAO().ViewDetail(result.CustomerID.ToString());
         IList <OrderDetailModels> product = new OrderDao().GetAll(id);
         IList <UserModels>        user    = new List <UserModels>();
         user.Add(dao);
         ViewData["KHACHHANG"] = user;
         ViewData["SANPHAM"]   = product;
         var order = new OrderDao();
         order.update(orders, id);
         SetAlert("Chỉnh sửa trạng thái thành công", "success");
         RedirectToAction("index");
     }
     return(View(orders));
 }
        public ActionResult VerPedido(string idSesion = "")
        {
            if (idSesion == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //List<ProductOrderModels> lobeProdsPedido = (List<ProductOrderModels>)Session[idSesion + "lobeProdsPedido"];
            List <ProductOrderModels> lobeProdsPedido = (List <ProductOrderModels>)Session["lobeProdsPedido"];

            if (lobeProdsPedido == null)
            {
                return(HttpNotFound());
            }
            OrderModels order = new OrderModels();

            order.lobeProducto = lobeProdsPedido;
            return(View(order));
        }
        public IHttpActionResult Order(int id, OrderModels.OrderInputModel orderModel)
        {
            var userId = HttpContext.Current.User.Identity.GetUserId();
            if (!this.ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }

            if (!this.User.Identity.IsAuthenticated)
            {
                return this.Unauthorized();
            }

            var searchedMeal = this.Data.Meals.All().FirstOrDefault(m => m.Id == id);
            if (searchedMeal == null)
            {
                return this.NotFound();
            }

            Order newOrder = new Order
            {
                MealId = searchedMeal.Id,
                Quantity = orderModel.quantity,
                UserId = userId,
                CreatedOn = DateTime.Now
            };

            this.Data.Orders.Add(newOrder);
            this.Data.SaveChanges();

            return this.Ok();
        }