Esempio n. 1
0
 public JsonResult Edit(BLL.Model.SalesDTO sales)
 {
     try
     {
         var valid = TryUpdateModel(sales);
         if (valid)
         {
             var data = Operation.UpdateSale(sales);
             //return RedirectToAction("Index");
             //Index();
             //return RedirectToAction("Index");
         }
         return(Json(new
         {
             Valid = valid,
             Errors = GetErrorsFromModelState(),
             //StudentsPartial = studentPartialViewHtml
         }));
     }
     catch
     {
         return(Json(new
         {
             Valid = false,
             Errors = GetErrorsFromModelState(),
             //StudentsPartial = studentPartialViewHtml
         }));
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Save a sale
 /// </summary>
 /// <param name="sale"></param>
 /// <returns></returns>
 public bool AddSale(BLL.Model.SalesDTO sale)
 {
     db.ProductSolds.Add(new ProductSold()
     {
         CustomerID = sale.CustomerId,
         ProductID  = sale.ProductId,
         StoreID    = sale.StoreId,
         DateSold   = sale.Date,
     });
     db.SaveChanges();
     return(true);
 }
Esempio n. 3
0
 public JsonResult Create(BLL.Model.SalesDTO sales)
 {
     try
     {
         var valid = Operation.AddSale(sales);
         return(Json(new
         {
             Valid = valid,
         }));
     }
     catch (Exception ex)
     {
         return(Json(new
         {
             Valid = false,
         }));
     }
 }
Esempio n. 4
0
        public JsonResult Edit(BLL.Model.SalesDTO sales)
        {
            try
            {
                var valid = Operation.UpdateSale(sales);

                return(Json(new
                {
                    Valid = valid,
                }));
            }
            catch
            {
                return(Json(new
                {
                    Valid = false,
                }));
            }
        }
Esempio n. 5
0
        public bool UpdateSale(BLL.Model.SalesDTO sale)
        {
            var existingSale = db.ProductSolds.FirstOrDefault(r => r.SalesID == sale.Id);

            if (existingSale != null)
            {
                existingSale.ProductID  = sale.ProductId;
                existingSale.CustomerID = sale.CustomerId;
                existingSale.StoreID    = sale.StoreId;
                existingSale.DateSold   = sale.Date;
                db.ProductSolds.Attach(existingSale);
                db.Entry(existingSale).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                return(true);
            }
            else
            {
                return(false);
            }
        }