public JsonResult Edit(BLL.Model.Store Store)
 {
     try
     {
         var valid = TryUpdateModel(Store);
         if (valid)
         {
             var Stores = Operation.UpdateStore(Store);
         }
         //return RedirectToAction("Index");
         return(Json(new
         {
             Valid = valid,
             Errors = GetErrorsFromModelState(),
             //StudentsPartial = studentPartialViewHtml
         }));
     }
     catch (Exception ex)
     {
         return(Json(new
         {
             result = "Error occured"
                      //StudentsPartial = studentPartialViewHtml
         }));
     }
 }
 public ActionResult Create(BLL.Model.Store Store)
 {
     try
     {
         // TODO: Add insert logic here
         var valid = TryUpdateModel(Store);
         if (valid)
         {
             var Stores = Operation.SaveStore(Store);
             //return RedirectToAction("Index");
             //Index();
             //return RedirectToAction("Index");
         }
         return(Json(new
         {
             Valid = valid,
             Errors = GetErrorsFromModelState(),
             //StudentsPartial = studentPartialViewHtml
         }));
     }
     catch
     {
         return(View());
     }
 }
Beispiel #3
0
 /// <summary>
 /// Save data to Store table
 /// </summary>
 /// <param name="store"></param>
 /// <returns></returns>
 public bool SaveStore(BLL.Model.Store store)
 {
     db.Stores.Add(
         new Store()
     {
         Name    = store.Name,
         Address = store.Address
     });
     db.SaveChanges();
     return(true);
 }
Beispiel #4
0
        public ActionResult Delete(int?id, BLL.Model.Store Store)
        {
            try
            {
                var store = operations.DeleteStore(id);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #5
0
 public ActionResult Edit(BLL.Model.Store store)
 {
     try
     {
         // TODO: Add update logic here
         operations.UpdateStore(store);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Beispiel #6
0
        public ActionResult Create(BLL.Model.Store store)
        {
            try
            {
                operations.SaveStore(store);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Beispiel #7
0
 public ActionResult Create(BLL.Model.Store Store)
 {
     try
     {
         var valid = Operation.SaveStore(Store);
         return(Json(new
         {
             Valid = valid,
         }));
     }
     catch
     {
         return(View());
     }
 }
Beispiel #8
0
        /// <summary>
        /// Update existing Store details
        /// </summary>
        /// <param name="store"></param>
        /// <returns></returns>
        public bool UpdateStore(BLL.Model.Store store)
        {
            var existingStore = db.Stores.FirstOrDefault(r => r.ID == store.Id);

            if (existingStore != null)
            {
                existingStore.Address = store.Address;
                existingStore.Name    = store.Name;
                db.Stores.Attach(existingStore);
                db.Entry(existingStore).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #9
0
 public JsonResult Edit(BLL.Model.Store Store)
 {
     try
     {
         var valid = Operation.UpdateStore(Store);
         return(Json(new
         {
             Valid = valid,
             //StudentsPartial = studentPartialViewHtml
         }));
     }
     catch (Exception ex)
     {
         return(Json(new
         {
             result = "Error occured"
                      //StudentsPartial = studentPartialViewHtml
         }));
     }
 }