public JsonResult AddOrder(WatchOrder model)
        {
            var succ = false;

            try
            {
                if (model.Client.ID != 0)
                {
                    var client = _context.Clients.First(x => x.ID == model.Client.ID);
                    model.ClientId = client.ID;
                    if (!string.IsNullOrEmpty(model.Client.Telephone))
                    {
                        client.Telephone = model.Client.Telephone;
                    }
                    client.Phone         = model.Client.Phone;
                    client.LastOrderDate = DateTime.Now;
                    model.Client         = null;
                }
                else
                {
                    model.Client.LastOrderDate = DateTime.Now;
                    model.Client.CreationDate  = DateTime.Now;
                }
                model.CreationDate = DateTime.Now;
                _context.WatchOrders.Add(model);
                _context.SaveChanges();
                succ = true;
            }
            catch (Exception ex)
            {
            }
            return(new JsonResult {
                Data = new { succ = succ }, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Пример #2
0
        public ActionResult UpdateQuantt(int id, int quantt)
        {
            WatchOrdList listWO = new WatchOrdList();

            if (Session["goods"] != null)
            {
                listWO = JsonSerializer.Deserialize <WatchOrdList>(Session["goods"].ToString());
            }
            WatchOrder WO = listWO.GetWObyID(id);

            WO.Quantity += quantt;
            if (WO.Quantity == 0)
            {
                listWO.Remove(WO);
            }


            Session["goods"] = JsonSerializer.Serialize(listWO);
            return(View("Index", listWO));
        }