Пример #1
0
        public ActionResult GridViewUpdatePartial(table_costumer item)
        {
            var model = db.table_costumer;

            if (ModelState.IsValid)
            {
                try
                {
                    var modelItem = model.FirstOrDefault(it => it.costumer_id == item.costumer_id);
                    if (modelItem != null)
                    {
                        this.UpdateModel(modelItem);
                        db.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    ViewBag.GeneralError = e.Message;
                }
            }
            else
            {
                ViewBag.GeneralError = "Please, correct all errors.";
            }
            return(GridViewPartial());
        }
Пример #2
0
        public ActionResult GridViewAddNewPartial(table_costumer item)
        {
            var model = db.table_costumer;

            if (ModelState.IsValid)
            {
                try
                {
                    model.Add(item);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    ViewBag.GeneralError = e.Message;
                }
            }
            else
            {
                ViewBag.GeneralError = "Please, correct all errors.";
            }
            return(GridViewPartial());
        }