Beispiel #1
0
        public ActionResult DetailPartial(int Id = 0)
        {
            AlertModel alertModel;

            alertService = new AlertService();

            if (Id == 0)
            {
                alertModel           = alertService.GetNewModel();
                alertModel._FormMode = FormModeEnum.New;
            }
            else
            {
                alertModel = alertService.GetById(Id);
                if (alertModel != null)
                {
                    alertModel._FormMode = FormModeEnum.Edit;
                }
                else
                {
                    throw new Exception("[VALIDATION]-Data not exists");
                }
            }

            return(PartialView(VIEW_FORM_PARTIAL, alertModel));
        }
Beispiel #2
0
        public ActionResult Add([ModelBinder(typeof(DevExpressEditorsBinder))]  AlertModel alertModel)
        {
            alertModel._UserId = (int)Session["userId"];

            alertService = new AlertService();


            if (ModelState.IsValid)
            {
                alertService.Add(alertModel);
                alertModel = alertService.GetNewModel();
            }
            else
            {
                string message = GetErrorModel();

                throw new Exception(string.Format("[VALIDATION] {0}", message));
            }


            alertModel._FormMode = Models.FormModeEnum.New;

            return(PartialView(VIEW_FORM_PARTIAL, alertModel));
        }