コード例 #1
0
        //
        // GET: /AppSetting/Details/By ID
        public ActionResult Details(int id)
        {
            var errorViewModel = new ErrorViewModel();

            try
            {
                var appSettings = _db.AppSettings.Find(id);
                if (appSettings != null)
                {
                    var viewModel = new AppSettingsViewModel() { AppSettingsId = appSettings.AppSettingsId, Name = appSettings.Name };
                    return PartialView("_Details", viewModel);
                }

                errorViewModel = ExceptionHelper.ExceptionErrorMessageForNullObject();
            }
            catch (Exception ex)
            {
                errorViewModel = ExceptionHelper.ExceptionErrorMessageFormat(ex);
            }

            return PartialView("_ErrorPopup", errorViewModel);
        }
コード例 #2
0
 //
 // GET: /AppSetting/Add
 public ActionResult Add()
 {
     var viewModel = new AppSettingsViewModel() { AppSettingsId = 0 };
     //return View();
     return PartialView("_AddOrEdit", viewModel);
 }
コード例 #3
0
        public ActionResult Save(AppSettingsViewModel appSettingsViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //add
                    if (appSettingsViewModel.AppSettingsId == 0 && appSettingsViewModel.ActionName == "Add")
                    {
                        var model = new AppSettings() { AppSettingsId = appSettingsViewModel.AppSettingsId, Name = appSettingsViewModel.Name };
                        _db.AppSettings.Add(model);
                    }
                    else if (appSettingsViewModel.ActionName == "Edit") //edit
                    {
                        AppSettings appSettings = _db.AppSettings.Find(appSettingsViewModel.AppSettingsId);

                        if (appSettings != null)
                        {

                            appSettings.AppSettingsId = appSettingsViewModel.AppSettingsId;
                            appSettings.Name = appSettingsViewModel.Name;
                            _db.Entry(appSettings).State = EntityState.Modified;

                        }
                        else
                        {
                            return Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, MessageType.warning.ToString(), ExceptionHelper.ExceptionMessageForNullObject()));
                        }

                    }

                    _db.SaveChanges();

                    //return Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.TrueString, MessageType.success.ToString(), "Saved Successfully."));
                    return Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.TrueString, appSettingsViewModel.ActionName, MessageType.success.ToString(), "Saved Successfully."));

                }

                return Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.TrueString, MessageType.success.ToString(), ExceptionHelper.ModelStateErrorFormat(ModelState)));
            }
            catch (Exception ex)
            {
                return Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.TrueString, MessageType.success.ToString(), ExceptionHelper.ExceptionMessageFormat(ex)));
            }
        }