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); } }
public void AddNewPredefinedFilter(PredefinedFilter userFilter) { var userFilterEntity = userFilter.MapTo<Domain.PredefinedFilter, Data.PredefinedFilter>(); _virtualOfficeEntities.PredefinedFilters.Add(userFilterEntity); _virtualOfficeEntities.SaveChanges(); }
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); } }