コード例 #1
0
        public ActionResult AddNewPredefinedFilter(PredefinedFilterViewModel predefinedFilterViewModel)
        {
            try
            {
                if (!ModelState.IsValid)
                    return View("Index", predefinedFilterViewModel);

                var userFilter = new PredefinedFilter()
                {
                    Name = predefinedFilterViewModel.Name,
                    Type = predefinedFilterViewModel.Type == "Column" ? 0 : 1,
                    Value = predefinedFilterViewModel.Value,
                    ColumnName = predefinedFilterViewModel.ColumnName,
                    ParameterName = predefinedFilterViewModel.ParameterName
                };

                _virtualOfficeToolManager.AddNewPredefinedFilter(userFilter);

                return RedirectToAction("Index");
            }
            catch (Exception exception)
            {
                ModelState.AddModelError("", "Errors while trying to add a new Predefined Filter. Please, try again later! :)");

                return View("Index", predefinedFilterViewModel);
            }
        }
コード例 #2
0
        public void AddNewPredefinedFilter(PredefinedFilter userFilter)
        {
            var userFilterEntity = userFilter.MapTo<Domain.PredefinedFilter, Data.PredefinedFilter>();

            _virtualOfficeEntities.PredefinedFilters.Add(userFilterEntity);

            _virtualOfficeEntities.SaveChanges();
        }
コード例 #3
0
        public ActionResult UpdatePredefinedFilter(PredefinedFilterViewModel predefinedFilterViewModel)
        {
            try
            {

                var predefinedFilter = new PredefinedFilter()
                {
                    Id= predefinedFilterViewModel.Id,
                    Name = predefinedFilterViewModel.Name,
                    Type = predefinedFilterViewModel.Type == "Column" ? 0 : 1,
                    Value = predefinedFilterViewModel.Value,
                    ColumnName = predefinedFilterViewModel.ColumnName,
                    ParameterName = predefinedFilterViewModel.ParameterName
                };

                _virtualOfficeToolManager.UpdatePredefinedFilter(predefinedFilter);

                return RedirectToAction("Index");
            }
            catch (Exception)
            {
                ModelState.AddModelError("", "Errors while trying to update the Predefined Filter. Please, try again later! :)");

                return View("Index", predefinedFilterViewModel);
            }
        }