Ejemplo n.º 1
0
        public ActionResult GridViewObjectPaymentsUpdate(Database.ObjectPayments item)
        {
            var model = dbObjectPayments.ObjectPayments;

            if (ModelState.IsValid)
            {
                try
                {
                    var modelItem = model.FirstOrDefault(it => it.id == item.id);
                    if (modelItem != null)
                    {
                        UpdateModel(modelItem);
                        dbObjectPayments.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            var modelToShow = dbObjectPayments.ObjectPayments.AsQueryable().Where(x => x.object_id == MySession.Current.ObjectId);

            return(PartialView("_GridViewObjectPayments", modelToShow.ToList()));
        }
Ejemplo n.º 2
0
        public ActionResult GridViewObjectPaymentsAddNew(Database.ObjectPayments item)
        {
            var model = dbObjectPayments.ObjectPayments;

            if (ModelState.IsValid)
            {
                try
                {
                    item.object_id = MySession.Current.ObjectId;
                    model.Add(item);
                    dbObjectPayments.SaveChanges();
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            var modelToShow = dbObjectPayments.ObjectPayments.AsQueryable().Where(x => x.object_id == MySession.Current.ObjectId);

            return(PartialView("_GridViewObjectPayments", modelToShow.ToList()));
        }