public async Task <IActionResult> Index() { var protectorProvider = _provider.GetService <IDataProtectionProvider>(); var protector = protectorProvider.CreateProtector(_dataProtectionKeys.ApplicationUserKey); var userProfile = await _userSvc.GetUserProfileByIdAsync(protector.Unprotect(_cookieSvc.Get("user_id"))); var addUserModel = new AddUserModel(); var protectorSendGrid = protectorProvider.CreateProtector(_dataProtectionKeys.SendGridProtectionKey); var dashboard = new DashBoardModel(); _adminBaseViewModel = new AdminBaseViewModel { Profile = userProfile, AddUser = addUserModel, AppSetting = _appSettings, SmtpOption = _writableSvcSmtpOptions.Value, SendGridOption = _writableSvcSendGridOptions.Value, SiteWideSetting = _writableSiteWideSettings.Value, Dashboard = dashboard }; _adminBaseViewModel.SendGridOption.SendGridKey = protectorSendGrid.Protect(_adminBaseViewModel.SendGridOption.SendGridKey); _adminBaseViewModel.SmtpOption.SmtpPassword = protectorSendGrid.Protect(_adminBaseViewModel.SmtpOption.SmtpPassword); return(View("Index", _adminBaseViewModel)); }
protected void InitAdminBaseViewModel(AdminBaseViewModel adminBaseViewModel) { adminBaseViewModel.CurrentLanguage = CultureInfo.CurrentCulture.Name; var languages = languageAdminService.GetAllLanguages(); SelectList languagesSelectList = new SelectList(languages, nameof(LanguageDto.LangCode), nameof(LanguageDto.LangName)); ViewBag.Languages = languagesSelectList; }
public ActionResult Details(int id) { var model = new AdminBaseViewModel <Contact>(); model.Item = _repo.FindBy(x => x.ID == id).FirstOrDefault(); return(View(model)); }
// GET: Admin/Forms public ActionResult Index() { var model = new AdminBaseViewModel <List <Contact> >(); model.Item = _repo.GetAll().OrderByDescending(x => x.Submitted).ToList(); return(View(model)); }
public ActionResult Details(int id) { var model = new AdminBaseViewModel <JobApplication>(); var ob = _repo.FindBy(x => x.ID == id).FirstOrDefault(); model.Item = ob; SetListPage(Url.Action("Index", new { t = ob.Job.JobType.ToString().Replace("_", "").ToLowerInvariant(), s = ob.Status.ToString().ToLowerInvariant() })); return(View(model)); }
protected void InitAdminBaseViewModel(AdminBaseViewModel adminBaseViewModel) { var permissions = GetAllPermissions(); adminBaseViewModel.CurrentLanguage = CultureInfo.CurrentCulture.Name; List <LanguageDto> languages = languageAdminService.GetAllLanguages(); SelectList languagesSelectList = new SelectList(languages, nameof(LanguageDto.LangCode), nameof(LanguageDto.LangName)); ViewBag.Languages = languagesSelectList; ViewBag.RecordStatusCombobox = recordStatusHelper.GetRecordStatusCombobox(); adminBaseViewModel.Menus = adminMenuProvider.GetAdminMenuTreeView(permissions); }
private async Task SetAdminBaseViewModel() { var protectorProvider = _provider.GetService <IDataProtectionProvider>(); var protector = protectorProvider.CreateProtector(_dataProtectionKeys.ApplicationUserKey); var userProfile = await _userService.GetUserProfileByIdAsync(protector.Unprotect(_cookieService.Get("user_id"))); var resetPassword = new ResetPasswordViewModel(); _adminBaseViewModel = new AdminBaseViewModel { Profile = userProfile, ResetPassword = resetPassword, }; }
public ActionResult Details(int id, AdminBaseViewModel <JobApplication> obj, FormCollection form) { var ob = _repo.FindBy(x => x.ID == id).FirstOrDefault(); ob.Notes = obj.Item.Notes; ob.Status = obj.Item.Status; _uow.Commit(); ModifiedItem(); SetListPage(Url.Action("Index", new { t = ob.Job.JobType.ToString().Replace("_", "").ToLowerInvariant(), s = ob.Status.ToString().ToLowerInvariant() })); return(RedirectToAction("Details", new AdminBaseViewModel <JobApplication> { Item = ob })); }
public async Task <IActionResult> Index() { var protectorProvider = _provider.GetService <IDataProtectionProvider>(); var protector = protectorProvider.CreateProtector(_dataProtectionKeys.ApplicationUserKey); var userProfile = await _userSvc.GetUserProfileByIdAsync(protector.Unprotect(_cookieSvc.Get("user_id"))); var addUserModel = new AddUserModel(); _adminBaseViewModel = new AdminBaseViewModel { Profile = userProfile, AddUser = addUserModel, AppSetting = _appSettings, SiteWideSetting = _writableSiteWideSettings.Value }; return(View("Index", _adminBaseViewModel)); }
private async Task SetAdminBaseViewModel() { var protectorProvider = _provider.GetService <IDataProtectionProvider>(); var protector = protectorProvider.CreateProtector(_dataProtectionKeys.ApplicationUserKey); var userProfile = await _userSvc.GetUserProfileByIdAsync(protector.Unprotect(_cookieSvc.Get("user_id"))); var resetPassword = new ResetPasswordViewModel(); _adminBaseViewModel = new AdminBaseViewModel { Profile = userProfile, AddUser = null, AppSetting = null, Dashboard = null, ResetPassword = resetPassword, SiteWideSetting = _writableSiteWideSettings.Value }; }
public ActionResult Index() { var appStatus = ApplicationStatus.New; var jobCat = "nondriving".Equals(Request.QueryString["t"], StringComparison.OrdinalIgnoreCase) ? JobType.Non_Driving : JobType.Driving; if (Request.QueryString["s"] != null) { appStatus = GetStatus(Request.QueryString["s"].ToString()); } ViewBag.JobCategory = jobCat; ViewBag.ApplicationStatus = appStatus; ViewBag.NewCount = _repo.GetAll().Where(x => x.Job.JobType == jobCat && x.Status == ApplicationStatus.New).Count(); var model = new AdminBaseViewModel <List <JobApplication> > { Item = _repo.GetAll().Where(x => x.Status == appStatus && x.Job.JobType == jobCat).OrderByDescending(x => x.Submitted).ToList() }; return(View(model)); }
public async Task <IActionResult> Permissions() { var protectorProvider = _provider.GetService <IDataProtectionProvider>(); var protector = protectorProvider.CreateProtector(_dataProtectionKeys.ApplicationUserKey); var userProfile = await _userSvc.GetUserProfileByIdAsync(protector.Unprotect(_cookieSvc.Get("user_id"))); var addUserModel = new AddUserModel(); _adminBaseViewModel = new AdminBaseViewModel { Profile = userProfile, AddUser = addUserModel, AppSetting = _appSettings, SiteWideSetting = _writableSiteWideSettings.Value, PermissionTypes = (List <PermissionType>) await _roleSvc.GetAllRolePermissionsTypesAsync() }; // (List<PermissionType>)await _roleSvc.GetAllRolePermissionsTypesAsync(); return(View("Permissions", _adminBaseViewModel)); }
public ActionResult Create(AdminBaseViewModel <AdminUser> model, int[] userRoles) { var user = model.Item; // ensure the email address is unique if (!_repo.IsEmailUnique(user.EmailAddress)) { ModelState.AddModelError("NonUnique", "The email address is not unique"); } HandlePassword(user, true); if (!ModelState.IsValid) { return(View("Edit", new AdminBaseViewModel <AdminUser> { Item = user })); } try { // handle roles AddUpdateRoles(user, userRoles); _repo.Add(user); _uow.Commit(); CreatedItem(); SetListPage(Url.Action("Index")); return(RedirectToAction("Edit", new { id = user.ID })); } catch (Exception ex) { RaiseError(ex); return(View("Edit", new AdminBaseViewModel <AdminUser> { Item = user })); } }
private async Task SetBaseViewModel() { var protectedUid = _cookieSvc.Get("user_id"); //If here is some problems , we should using denpendency injection var protectProvider = _provider.GetService <IDataProtectionProvider>(); var protector = protectProvider.CreateProtector(_dataProtectionKeys.ApplicationUserKey); var unprotectedUID = protector.Unprotect(protectedUid); var userProfile = await _userSvc.GetUserProfileByIdAsync(unprotectedUID); var resetPassword = new ResetPasswordViewModel(); _adminBaseViewModel = new AdminBaseViewModel() { Profile = userProfile, AddUser = null, Dashboard = null, AppSetting = null, SendGridOption = null, SmtpOption = null, ResetPassword = null, SiteWideSetting = null }; }
public virtual ActionResult Edit(int id, AdminBaseViewModel <T> ob, FormCollection form) { return(Save(id, ob.Item, form)); }
public virtual ActionResult Create(AdminBaseViewModel <T> ob, FormCollection form) { return(Save(null, ob.Item, form)); }
public ActionResult Edit(int id, AdminBaseViewModel <AdminUser> model, int[] userRoles) { var user = model.Item; // get the user from the database var userFromDatabase = _repo.FindById(id); user.ID = id; // deal with possible password blanks HandlePassword(user, false); // kind of hack, but let's try to revalidate the modelstate ModelState.Clear(); TryValidateModel(user); // let's check to see if the email is unique if (userFromDatabase.EmailAddress != user.EmailAddress) { if (!_repo.IsEmailUnique(user.EmailAddress)) { ModelState.AddModelError("NonUnique", "The email address is not unique"); } } if (!ModelState.IsValid) { return(View(new AdminBaseViewModel <AdminUser> { Item = user })); } try { // set the ID from URL to prevent any screwness userFromDatabase.ExpireAllSessions(); _sessionRepo.ExpireAllSessionsForUser(userFromDatabase.EmailAddress); _uow.Commit(); _repo.Edit(user); AddUpdateRoles(userFromDatabase, userRoles); _uow.Commit(); ModifiedItem(); if (!Request.RequestContext.HttpContext.User.IsInRole(Constants.ROLE_USERS_IM) && userFromDatabase.EmailAddress == Request.RequestContext.HttpContext.User.Identity.Name) { return(RedirectToAction("Logout", "Account")); } SetListPage(Url.Action("Index")); return(RedirectToAction("Edit", new { id = user.ID })); } catch (Exception ex) { RaiseError(ex); return(View(new AdminBaseViewModel <AdminUser> { Item = user })); } }