// // GET: /Right/Details/By ID public ActionResult Details(int id) { var errorViewModel = new ErrorViewModel(); try { //var right = _rightRepository.GetById(id); var right = _rightRepository.GetAll().SingleOrDefault(x => x.RightId == id); if (right != null) { var singleOrDefaultApplication = _applicationRepository.GetAll().SingleOrDefault(x => x.ApplicationId == right.ApplicationId); var singleOrDefaultModule = _moduleRepository.GetAll().SingleOrDefault(x => x.ModuleId == right.ModuleId); if (singleOrDefaultApplication != null && singleOrDefaultModule != null) { var viewModel = new RightViewModel() { RightId = right.RightId, RightName = right.RightName, RightTitle = right.RightTitle, Description = right.Description, ApplicationId = Convert.ToInt32(right.ApplicationId), ApplicationName = singleOrDefaultApplication.ApplicationName, ModuleId = Convert.ToInt32(right.ModuleId), ModuleName = singleOrDefaultModule.ModuleName }; return PartialView("_Details", viewModel); } } errorViewModel = ExceptionHelper.ExceptionErrorMessageForNullObject(); } catch (Exception ex) { errorViewModel = ExceptionHelper.ExceptionErrorMessageFormat(ex); } return PartialView("_ErrorPopup", errorViewModel); }
// // GET: /Module/Details/By ID public ActionResult Details(int id) { var errorViewModel = new ErrorViewModel(); try { //var module = _moduleRepository.GetById(id); var module = _moduleRepository.GetAll().SingleOrDefault(x => x.ModuleId == id); if (module != null) { var singleOrDefault = _applicationRepository.GetAll().SingleOrDefault(x => x.ApplicationId == module.ApplicationId); if (singleOrDefault != null) { var viewModel = new ModuleViewModel() { ModuleId = module.ModuleId, ModuleName = module.ModuleName, Description = module.Description, ModuleTitle = module.ModuleTitle, ApplicationId = module.ApplicationId, ApplicationName = singleOrDefault.ApplicationName }; return PartialView("_Details", viewModel); } } errorViewModel = ExceptionHelper.ExceptionErrorMessageForNullObject(); } catch (Exception ex) { errorViewModel = ExceptionHelper.ExceptionErrorMessageFormat(ex); } return PartialView("_ErrorPopup", errorViewModel); }
// // GET: /UserGroup/Details/By ID public ActionResult Details(int id) { var errorViewModel = new ErrorViewModel(); try { //var group = _groupRepository.GetById(id); var group = _groupRepository.GetAll().SingleOrDefault(x => x.GroupId == id); if (group != null) { var viewModel = new GroupViewModel() { GroupId = group.GroupId, GroupName = group.GroupName, Description = group.Description }; return PartialView("_Details", viewModel); } errorViewModel = ExceptionHelper.ExceptionErrorMessageForNullObject(); } catch (Exception ex) { errorViewModel = ExceptionHelper.ExceptionErrorMessageFormat(ex); } return PartialView("_ErrorPopup", errorViewModel); }
public static ErrorViewModel ExceptionErrorMessageFormat(Exception ex) { var errorViewModel = new ErrorViewModel(); string message = "Error: There was a problem while processing your request: " + ex.Message; if (ex.InnerException != null) { Exception inner = ex.InnerException; if (inner is System.Data.Common.DbException) message = "Database is currently experiencing problems. " + inner.Message; else if (inner is System.Data.UpdateException) message = "Datebase is currently updating problem."; else if (inner is System.Data.EntityException) message = "Entity is problem."; else if (inner is NullReferenceException) message = "There are one or more required fields that are missing."; else if (inner is ArgumentException) { string paramName = ((ArgumentException)inner).ParamName; message = string.Concat("The ", paramName, " value is illegal."); } else if (inner is ApplicationException) message = "Exception in application" + inner.Message; else message = inner.Message; } errorViewModel.ErrorType = "error"; errorViewModel.ErrorMessage = message; return errorViewModel; }
// // GET: /Menu/Details/By ID public ActionResult Details(int id) { var errorViewModel = new ErrorViewModel(); try { //var menu = _menuRepository.GetById(id); var menu = _menuRepository.GetAll().SingleOrDefault(x => x.MenuId == id); if (menu != null) { var singleOrDefaultParentMenu = _menuRepository.GetAll().SingleOrDefault(x => x.MenuId == menu.ParentMenuId); var singleOrDefaultApplication = _applicationRepository.GetAll().SingleOrDefault(x => x.ApplicationId == menu.ApplicationId); var singleOrDefaultModule = _moduleRepository.GetAll().SingleOrDefault(x => x.ModuleId == menu.ModuleId); if (singleOrDefaultApplication != null && singleOrDefaultModule != null) { var viewModel = new MenuViewModel() { MenuId = menu.MenuId, MenuName = menu.MenuName, MenuCaption = menu.MenuCaption, MenuCaptionBng = menu.MenuCaptionBng, PageUrl = menu.PageUrl, SerialNo = Convert.ToInt32(menu.SerialNo), OrderNo = Convert.ToInt32(menu.OrderNo), ParentMenuId = Convert.ToInt32(menu.ParentMenuId), ParentMenuName = singleOrDefaultParentMenu.MenuName, ApplicationId = menu.ApplicationId, ApplicationName = singleOrDefaultApplication.ApplicationName, ModuleId = menu.ModuleId, ModuleName = singleOrDefaultModule.ModuleName }; return PartialView("_Details", viewModel); } } errorViewModel = ExceptionHelper.ExceptionErrorMessageForNullObject(); } catch (Exception ex) { errorViewModel = ExceptionHelper.ExceptionErrorMessageFormat(ex); } return PartialView("_ErrorPopup", errorViewModel); }
public static ErrorViewModel ExceptionErrorMessageForNullObject() { var errorViewModel = new ErrorViewModel(); string message = "Requested object could not found."; errorViewModel.ErrorType = "warn"; errorViewModel.ErrorMessage = message; return errorViewModel; }
public static ErrorViewModel ExceptionErrorMessageForCommon() { var errorViewModel = new ErrorViewModel(); string message = "Oops! Exception in application."; errorViewModel.ErrorType = "info"; errorViewModel.ErrorMessage = message; return errorViewModel; }
// // GET: /Company/Details/By ID public ActionResult Details(int id) { var errorViewModel = new ErrorViewModel(); try { //var company = _companyRepository.GetById(id); var company = _companyRepository.GetAll().SingleOrDefault(x => x.CompanyId == id); if (company != null) { var viewModel = new CompanyViewModel() { CompanyId = company.CompanyId, CompanyName = company.CompanyName, Address = company.Address }; return PartialView("_Details", viewModel); } errorViewModel = ExceptionHelper.ExceptionErrorMessageForNullObject(); } catch (Exception ex) { errorViewModel = ExceptionHelper.ExceptionErrorMessageFormat(ex); } return PartialView("_ErrorPopup", errorViewModel); }
// // GET: /Application/Details/By ID public ActionResult Details(int id) { var errorViewModel = new ErrorViewModel(); try { //var application = _applicationRepository.GetById(id); var application = _applicationRepository.GetAll().SingleOrDefault(x => x.ApplicationId == id); if (application != null) { var viewModel = new ApplicationViewModel() { ApplicationId = application.ApplicationId, ApplicationName = application.ApplicationName, Description = application.Description, ApplicationTitle = application.ApplicationTitle }; return PartialView("_Details", viewModel); } errorViewModel = ExceptionHelper.ExceptionErrorMessageForNullObject(); } catch (Exception ex) { errorViewModel = ExceptionHelper.ExceptionErrorMessageFormat(ex); } return PartialView("_ErrorPopup", errorViewModel); }
// // GET: /Right/Edit/By ID public ActionResult Edit(int id) { var errorViewModel = new ErrorViewModel(); try { //var right = _rightRepository.GetById(id); var right = _rightRepository.GetAll().SingleOrDefault(x => x.RightId == id); if (right != null) { var moduleList = SelectListItemExtension.PopulateDropdownList(_moduleRepository.GetAll().ToList<TblModule>(), "ModuleId", "ModuleName", isEdit: true, selectedValue: right.ModuleId.ToString()).ToList(); var applicationList = SelectListItemExtension.PopulateDropdownList(_applicationRepository.GetAll().ToList<TblApplication>(), "ApplicationId", "ApplicationName", isEdit: true, selectedValue: right.ApplicationId.ToString()).ToList(); var singleOrDefaultApplication = _applicationRepository.GetAll().SingleOrDefault(x => x.ApplicationId == right.ApplicationId); var singleOrDefaultModule = _moduleRepository.GetAll().SingleOrDefault(x => x.ModuleId == right.ModuleId); if (singleOrDefaultApplication != null && singleOrDefaultModule != null) { var viewModel = new RightViewModel() { RightId = right.RightId, RightName = right.RightName, RightTitle = right.RightTitle, Description = right.Description, ApplicationId = Convert.ToInt32(right.ApplicationId), ApplicationName = singleOrDefaultApplication != null ? singleOrDefaultApplication.ApplicationName : null, ddlApplications = applicationList, ModuleId = Convert.ToInt32(right.ModuleId), ModuleName = singleOrDefaultModule != null ? singleOrDefaultModule.ModuleName : null, ddlModules = moduleList }; return PartialView("_AddOrEdit", viewModel); } } errorViewModel = ExceptionHelper.ExceptionErrorMessageForNullObject(); } catch (Exception ex) { errorViewModel = ExceptionHelper.ExceptionErrorMessageFormat(ex); } return PartialView("_ErrorPopup", errorViewModel); }
// // GET: /Module/Edit/By ID public ActionResult Edit(int id) { var errorViewModel = new ErrorViewModel(); try { //var module = _moduleRepository.GetById(id); var module = _moduleRepository.GetAll().SingleOrDefault(x => x.ModuleId == id); if (module != null) { var applicationList = SelectListItemExtension.PopulateDropdownList(_applicationRepository.GetAll().ToList<TblApplication>(), "ApplicationId", "ApplicationName", isEdit: true, selectedValue: module.ApplicationId.ToString()).ToList(); var singleOrDefault = _applicationRepository.GetAll().SingleOrDefault(x => x.ApplicationId == module.ApplicationId); if (singleOrDefault != null) { var viewModel = new ModuleViewModel() { ModuleId = module.ModuleId, ModuleName = module.ModuleName, Description = module.Description, ModuleTitle = module.ModuleTitle, ApplicationId = module.ApplicationId, ApplicationName = singleOrDefault.ApplicationName, ddlApplications = applicationList }; return PartialView("_AddOrEdit", viewModel); } } errorViewModel = ExceptionHelper.ExceptionErrorMessageForNullObject(); } catch (Exception ex) { errorViewModel = ExceptionHelper.ExceptionErrorMessageFormat(ex); } return PartialView("_ErrorPopup", errorViewModel); }
// // GET: /Menu/Edit/By ID public ActionResult Edit(int id) { var errorViewModel = new ErrorViewModel(); try { //var menu = _menuRepository.GetById(id); var menu = _menuRepository.GetAll().SingleOrDefault(x => x.MenuId == id); if (menu != null) { var parentMenuList = SelectListItemExtension.PopulateDropdownList(_menuRepository.GetAll().ToList<TblMenu>(), "MenuId", "MenuName", isEdit: true, selectedValue: menu.ParentMenuId.ToString()).ToList(); var moduleList = SelectListItemExtension.PopulateDropdownList(_moduleRepository.GetAll().ToList<TblModule>(), "ModuleId", "ModuleName", isEdit: true, selectedValue: menu.ModuleId.ToString()).ToList(); var applicationList = SelectListItemExtension.PopulateDropdownList(_applicationRepository.GetAll().ToList<TblApplication>(), "ApplicationId", "ApplicationName", isEdit: true, selectedValue: menu.ApplicationId.ToString()).ToList(); var singleOrDefaultParentMenu = _menuRepository.GetAll().SingleOrDefault(x => x.MenuId == menu.ParentMenuId); var singleOrDefaultApplication = _applicationRepository.GetAll().SingleOrDefault(x => x.ApplicationId == menu.ApplicationId); var singleOrDefaultModule = _moduleRepository.GetAll().SingleOrDefault(x => x.ModuleId == menu.ModuleId); if (singleOrDefaultApplication != null && singleOrDefaultModule != null) { var viewModel = new MenuViewModel() { MenuId = menu.MenuId, MenuName = menu.MenuName, MenuCaption = menu.MenuCaption, MenuCaptionBng = menu.MenuCaptionBng, PageUrl = menu.PageUrl, SerialNo = Convert.ToInt32(menu.SerialNo), OrderNo = Convert.ToInt32(menu.OrderNo), ParentMenuId = Convert.ToInt32(menu.ParentMenuId), ParentMenuName = singleOrDefaultParentMenu != null ? singleOrDefaultParentMenu.MenuName : null, ddlParentMenus = parentMenuList, ApplicationId = menu.ApplicationId, ApplicationName = singleOrDefaultApplication != null ? singleOrDefaultApplication.ApplicationName : null, ddlApplications = applicationList, ModuleId = menu.ModuleId, ModuleName = singleOrDefaultModule != null ? singleOrDefaultModule.ModuleName : null, ddlModules = moduleList }; return PartialView("_AddOrEdit", viewModel); } } errorViewModel = ExceptionHelper.ExceptionErrorMessageForNullObject(); } catch (Exception ex) { errorViewModel = ExceptionHelper.ExceptionErrorMessageFormat(ex); } return PartialView("_ErrorPopup", errorViewModel); }
// // GET: /UserGroup/Edit/By ID public ActionResult Edit(int id) { var errorViewModel = new ErrorViewModel(); try { //var group = _groupRepository.GetById(id); var group = _groupRepository.GetAll().SingleOrDefault(x => x.GroupId == id); if (group != null) { var moduleList = SelectListItemExtension.PopulateDropdownList(_moduleRepository.GetAll().ToList<TblModule>(), "ModuleId", "ModuleName").ToList(); var applicationList = SelectListItemExtension.PopulateDropdownList(_applicationRepository.GetAll().ToList<TblApplication>(), "ApplicationId", "ApplicationName").ToList(); var viewModel = new GroupViewModel() { GroupId = group.GroupId, GroupName = group.GroupName, Description = group.Description, ddlApplications = applicationList, ddlModules = moduleList }; return PartialView("_AddOrEdit", viewModel); } errorViewModel = ExceptionHelper.ExceptionErrorMessageForNullObject(); } catch (Exception ex) { errorViewModel = ExceptionHelper.ExceptionErrorMessageFormat(ex); } return PartialView("_ErrorPopup", errorViewModel); }
// // GET: /User/Details/By ID public ActionResult Details(int id) { var errorViewModel = new ErrorViewModel(); try { //var user = _userRepository.GetById(id); var user = _userRepository.GetAll().SingleOrDefault(x => x.UserId == id); if (user != null) { var singleOrDefaultGroup = _groupRepository.GetAll().SingleOrDefault(x => x.GroupId == user.GroupId); var singleOrDefaultApplication = _applicationRepository.GetAll().SingleOrDefault(x => x.ApplicationId == user.ApplicationId); var singleOrDefaultEmployee = _employeeRepository.GetAll().SingleOrDefault(x => x.EmployeeId == user.EmployeeId); if (singleOrDefaultApplication != null && singleOrDefaultGroup != null && singleOrDefaultEmployee != null) { var viewModel = new UserViewModel() { UserId = user.UserId, FirstName = user.FirstName, LastName = user.LastName, LoginId = user.LoginId, EmailAddress = user.EmailAddress, Phone = user.Phone, Password = user.Password, LastLoginDate = Convert.ToDateTime(user.LastLoginDate), Status = user.Status, Comment = user.Comment, GroupId = Convert.ToInt32(user.GroupId), GroupName = singleOrDefaultGroup.GroupName, ApplicationId = Convert.ToInt32(user.ApplicationId), ApplicationName = singleOrDefaultApplication.ApplicationName, EmployeeId = Convert.ToInt32(user.EmployeeId), EmployeeName = singleOrDefaultEmployee.EmployeeName }; return PartialView("_Details", viewModel); } } errorViewModel = ExceptionHelper.ExceptionErrorMessageForNullObject(); } catch (Exception ex) { errorViewModel = ExceptionHelper.ExceptionErrorMessageFormat(ex); } return PartialView("_ErrorPopup", errorViewModel); }
// // GET: /User/Edit/By ID public ActionResult Edit(int id) { var errorViewModel = new ErrorViewModel(); try { //var user = _userRepository.GetById(id); var user = _userRepository.GetAll().SingleOrDefault(x => x.UserId == id); if (user != null) { var applicationList = SelectListItemExtension.PopulateDropdownList(_applicationRepository.GetAll().ToList<TblApplication>(), "ApplicationId", "ApplicationName", isEdit: true, selectedValue: user.ApplicationId.ToString()).ToList(); var moduleList = SelectListItemExtension.PopulateDropdownList(_moduleRepository.GetAll().ToList<TblModule>(), "ModuleId", "ModuleName").ToList(); var groupList = SelectListItemExtension.PopulateDropdownList(_groupRepository.GetAll().ToList<TblGroup>(), "GroupId", "GroupName", isEdit: true, selectedValue: user.GroupId.ToString()).ToList(); var employeeList = SelectListItemExtension.PopulateDropdownList(_employeeRepository.GetAll().ToList<TblEmployee>(), "EmployeeId", "EmployeeName", isEdit: true, selectedValue: user.EmployeeId.ToString()).ToList(); var roleList = _roleRepository.GetAll().Select(x => new KendoTreeviewViewModel { Id = x.RoleId.ToString(), Text = x.RoleName }).ToList(); var singleOrDefaultGroup = _groupRepository.GetAll().SingleOrDefault(x => x.GroupId == user.GroupId); var singleOrDefaultApplication = _applicationRepository.GetAll().SingleOrDefault(x => x.ApplicationId == user.ApplicationId); var singleOrDefaultEmployee = _employeeRepository.GetAll().SingleOrDefault(x => x.EmployeeId == user.EmployeeId); if (singleOrDefaultApplication != null && singleOrDefaultGroup != null && singleOrDefaultEmployee != null) { var viewModel = new UserViewModel() { UserId = user.UserId, FirstName = user.FirstName, LastName = user.LastName, LoginId = user.LoginId, EmailAddress = user.EmailAddress, Phone = user.Phone, Password = user.Password, LastLoginDate = Convert.ToDateTime(user.LastLoginDate), Status = user.Status, Comment = user.Comment, GroupId = Convert.ToInt32(user.GroupId), GroupName = singleOrDefaultGroup.GroupName, ApplicationId = Convert.ToInt32(user.ApplicationId), ApplicationName = singleOrDefaultApplication.ApplicationName, EmployeeId = Convert.ToInt32(user.EmployeeId), EmployeeName = singleOrDefaultEmployee.EmployeeName, ddlApplications = applicationList, ddlModules = moduleList, ddlGroups = groupList, ddlEmployees = employeeList, RoleTreeViewModelList = roleList }; return PartialView("_AddOrEdit", viewModel); } } errorViewModel = ExceptionHelper.ExceptionErrorMessageForNullObject(); } catch (Exception ex) { errorViewModel = ExceptionHelper.ExceptionErrorMessageFormat(ex); } return PartialView("_ErrorPopup", errorViewModel); }
// // GET: /Application/Edit/By ID public ActionResult Edit(int id) { var errorViewModel = new ErrorViewModel(); try { //var application = _applicationRepository.GetById(id); var application = _applicationRepository.GetAll().SingleOrDefault(x => x.ApplicationId == id); if (application != null) { var companyList = SelectListItemExtension.PopulateDropdownList(_companyRepository.GetAll().ToList<TblCompany>(), "CompanyId", "CompanyName", isEdit: true, selectedValue: application.CompanyId.ToString()).ToList(); var singleOrDefaultCompany = _applicationRepository.GetAll().SingleOrDefault(x => x.CompanyId == application.CompanyId); if (singleOrDefaultCompany != null) { var viewModel = new ApplicationViewModel() { ApplicationId = application.ApplicationId, ApplicationName = application.ApplicationName, Description = application.Description, ApplicationTitle = application.ApplicationTitle, ddlCompanies = companyList }; return PartialView("_AddOrEdit", viewModel); } } errorViewModel = ExceptionHelper.ExceptionErrorMessageForNullObject(); } catch (Exception ex) { errorViewModel = ExceptionHelper.ExceptionErrorMessageFormat(ex); } return PartialView("_ErrorPopup", errorViewModel); }