Esempio n. 1
0
        public ActionResult GridViewProsthesisPartialUpdate(Database.Treatment item)
        {
            var model = dbTreatment.Treatment;

            if (ModelState.IsValid)
            {
                try
                {
                    var modelItem = model.FirstOrDefault(it => it.id == item.id);
                    if (modelItem != null)
                    {
                        this.UpdateModel(modelItem);
                        dbTreatment.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            var modelToShow = dbTreatment.Treatment.ToList().Where(x => x.customer_id == MySession.Current.CustomerId &&
                                                                   x.treatment_type == (int)TreatmentType.Prosthesis);

            return(PartialView("_GridViewProsthesisPartial", modelToShow.ToList()));
        }
Esempio n. 2
0
        public ActionResult GridViewProsthesisPartialAddNew(Database.Treatment item)
        {
            var model = dbTreatment.Treatment;

            if (ModelState.IsValid)
            {
                try
                {
                    item.customer_id    = MySession.Current.CustomerId;
                    item.treatment_type = (int)TreatmentType.Prosthesis;
                    model.Add(item);
                    dbTreatment.SaveChanges();
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            var modelToShow = dbTreatment.Treatment.ToList().Where(x => x.customer_id == MySession.Current.CustomerId &&
                                                                   x.treatment_type == (int)TreatmentType.Prosthesis);

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