Ejemplo n.º 1
0
        public ActionResult GridViewPartialUpdate([ModelBinder(typeof(XpoModelBinder))] Kundenarten obj)
        {
            var model = unitOfWork.Query <Kundenarten>();

            if (ModelState.IsValid)
            {
                try
                {
                    // Insert here a code to update the item in your model
                    var item = unitOfWork.FindObject <Kundenarten>(CriteriaOperator.Parse("Oid==?", obj.Oid));
                    if (obj != null)
                    {
                        item.Kundenart = obj.Kundenart;
                        item.Save();
                        unitOfWork.CommitChanges();
                    }
                    else
                    {
                        ViewData["EditError"] = "Something went wrong.";
                    }
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            return(PartialView("~/Views/CustomerTypes/_GridViewPartial.cshtml", model));
        }
Ejemplo n.º 2
0
        public ActionResult GridViewPartialAddNew([ModelBinder(typeof(XpoModelBinder))] Kundenarten obj)
        {
            var model = unitOfWork.Query <Kundenarten>();

            if (ModelState.IsValid)
            {
                try
                {
                    // Insert here a code to insert the new item in your model

                    new Kundenarten(unitOfWork)
                    {
                        Kundenart = obj.Kundenart
                    };
                    unitOfWork.CommitChanges();
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            return(PartialView("~/Views/CustomerTypes/_GridViewPartial.cshtml", model.ToList()));
        }