예제 #1
0
        public ActionResult CustomerPartialUpdate(Database.Customer item)
        {
            var model = dbCustomer.Customer;

            if (ModelState.IsValid)
            {
                try
                {
                    var modelItem = model.FirstOrDefault(it => it.id == item.id);
                    if (modelItem != null)
                    {
                        this.UpdateModel(modelItem);
                        dbCustomer.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            var modelShow = dbCustomer.Customer.ToList().Where(x => x.user_id == MySession.Current.UserGuid);

            return(PartialView("_CustomerPartial", modelShow.ToList()));
        }
예제 #2
0
        public ActionResult CustomerPartialAddNew(Database.Customer item)
        {
            var model = dbCustomer.Customer;

            if (ModelState.IsValid)
            {
                try
                {
                    item.user_id = MySession.Current.UserGuid;
                    model.Add(item);
                    dbCustomer.SaveChanges();
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            var modelShow = dbCustomer.Customer.ToList().Where(x => x.user_id == MySession.Current.UserGuid);

            return(PartialView("_CustomerPartial", modelShow.ToList()));
        }