public ActionResult BranchAdmin() { List <BranchAdminView> branchesAdminView = BranchAdminHelpers.GetBranchAdminViewList(User); ViewBag.CurrentUserId = AppUserHelpers.GetAppUser(User).AppUserId; return(View(branchesAdminView)); }
public ActionResult Index() { //Show basic web page unless the user is logged in if (User.Identity.IsAuthenticated) { AppUser appUser = AppUserHelpers.GetAppUser(User); //If user has not finished setting up user details (i.e. not linked to organisation) then force user to finish details else go to Dashboard switch (appUser.EntityStatus) { case EntityStatusEnum.Active: return(RedirectToAction("Dashboard", "Home")); case EntityStatusEnum.AwaitingOrganisationDetails: return(RedirectToAction("OrganisationDetails", "Home")); case EntityStatusEnum.OnHold: return(RedirectToAction("Logout", "Account")); default: //other status would have been dealt with so just show home/index view break; } } return(View()); }
public ActionResult ChangeCurrentBranchForUser(List <UserAdminView> modelDetails, Guid appUserId, Guid branchId) { //modelDetails coming through as blank so for now just update this value immediatetly, return and refresh data AppUserHelpers.UpdateCurrentBranchId(appUserId, branchId); return(Json(new { success = true })); }
public ActionResult Edit(AppUserEditView model) { if (ModelState.IsValid) { if (Request.Form["submitbutton"] != null) { AppUserHelpers.UpdateAppUserFromAppUserEditView(db, model); return(RedirectToAction(model.CallingAction, model.CallingController)); } return(RedirectToAction("Edit")); } Branch userBranch = BranchHelpers.GetCurrentBranchForUser(AppUserHelpers.GetGuidFromUserGetAppUserId(User.Identity.GetAppUserId())); //DropDowns ViewBag.BranchList = ControlHelpers.AllBranchesForCompanyListDropDown(userBranch.CompanyId, userBranch.BranchId); ViewBag.UserRoleList = ControlHelpers.UserRoleEnumListDropDown(); ViewBag.EntityStatusList = ControlHelpers.EntityStatusEnumListDropDown(); //Counters if (model.UserFriendListView == null) { model.UserFriendListView = new List <FriendView>(); } if (model.UserBranchFriendListView == null) { model.UserBranchFriendListView = new List <FriendView>(); } if (model.UserCompanyFriendListView == null) { model.UserCompanyFriendListView = new List <FriendView>(); } ViewBag.UserFriendCount = model.UserFriendListView.Count(); ViewBag.UserBranchFriendCount = model.UserBranchFriendListView.Count(); ViewBag.UserCompanyFriendCount = model.UserCompanyFriendListView.Count(); if (model.UserBlockListView == null) { model.UserBlockListView = new List <BlockView>(); } if (model.UserBranchBlockListView == null) { model.UserBranchBlockListView = new List <BlockView>(); } if (model.UserCompanyBlockListView == null) { model.UserCompanyBlockListView = new List <BlockView>(); } ViewBag.UserBlockCount = model.UserBlockListView.Count(); ViewBag.UserBranchBlockCount = model.UserBranchBlockListView.Count(); ViewBag.UserCompanyBlockCount = model.UserCompanyBlockListView.Count(); //rebuild group model model.GroupListViewsForUserOnly = GroupViewHelpers.GetGroupEditViewForForUserOnly(db, model.AppUserId); return(View(model)); }
public ActionResult OrganisationDetails([Bind(Include = "AppUserId,SelectedOrganisationId,OrganisationName,BusinessType,AddressLine1,AddressLine2,AddressLine3,AddressTownCity,AddressCounty,AddressPostcode,TelephoneNumber,Email,Website,ContactName,CompanyRegistrationDetails,CharityRegistrationDetails,VATRegistrationDetails,ListingPrivacyLevel,PrivacyLevel,GroupPrivacyLevel")] HomeOrganisationDetailsView model) { if (Request.Form["resetbutton"] != null) { return(RedirectToAction("OrganisationDetails", "Home")); } if (ModelState.IsValid) { //If the 'Submit' button pressed then update tables, else leave as are so that on reload it takes original values once again. if (Request.Form["submitbutton"] != null) { if (model.SelectedOrganisationId == null) { //Add organisation update appUser with this organisationId Organisation organisation = OrganisationHelpers.CreateOrganisation(model, User); AppUserHelpers.UpdateAppUserOrganisationId(User, organisation.OrganisationId); AppUserHelpers.UpdateAppUserRoleAndEntityStatus(User, UserRoleEnum.Admin, EntityStatusEnum.Active, User); ApplicationUser user = UserHelpers.UpdateUserRole(User, UserRoleEnum.Admin); } else { AppUserHelpers.UpdateAppUserOrganisationId(User, model.SelectedOrganisationId.Value); AppUserHelpers.UpdateAppUserRoleAndEntityStatus(User, UserRoleEnum.User, EntityStatusEnum.OnHold, User); } return(RedirectToAction("Index", "Home")); } } //DropDown - rebuild and clear selected option ViewBag.OrganisationList = ControlHelpers.AllOrganisationsListDropDown(); model.SelectedOrganisationId = null; return(View(model)); }
public ActionResult ApproveTask(Guid?userTaskId) { if (userTaskId.HasValue) { UserTask userTask = UserTaskHelpers.GetUserTask(userTaskId.Value); switch (userTask.TaskType) { case TaskTypeEnum.UserOnHold: //Make AppUser active AppUserHelpers.UpdateEntityStatus(userTask.ReferenceKey, EntityStatusEnum.Active); break; case TaskTypeEnum.BranchOnHold: //Make Branch active BranchHelpers.UpdateEntityStatus(userTask.ReferenceKey, EntityStatusEnum.Active); break; } //close the Task UserTaskHelpers.UpdateEntityStatus(userTask.UserTaskId, EntityStatusEnum.Closed); return(Json(new { success = true })); } else { return(Json(new { success = false })); } }
//// GET: AppUsers/Edit/5 //public ActionResult Edit() //{ // Guid id = AppUserHelpers.GetAppUserIdFromUser(User); // if (id == null) // { // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); // } // AppUser appUser = db.AppUsers.Find(id); // if (appUser == null) // { // return HttpNotFound(); // } // return View(appUser); //} //// POST: AppUsers/Edit/5 //// To protect from overposting attacks, please enable the specific properties you want to bind to, for //// more details see https://go.microsoft.com/fwlink/?LinkId=317598. //[HttpPost] //[ValidateAntiForgeryToken] //public ActionResult Edit([Bind(Include = "AppUserId,FirstName,LastName,EntityStatus,OrganisationId,LoginEmail,PrivacyLevel,UserRole,MaxDistanceFilter,MaxAgeFilter,SelectionLevelFilter,DisplayMyOrganisationListingsFilter,RecordChange,RecordChangeOn,RecordChangeBy")] AppUser appUser) //{ // if (ModelState.IsValid) // { // db.Entry(appUser).State = EntityState.Modified; // db.SaveChanges(); // return RedirectToAction("Index"); // } // return View(appUser); //} //// GET: AppUsers/Delete/5 //public ActionResult Delete(Guid? id) //{ // if (id == null) // { // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); // } // AppUser appUser = db.AppUsers.Find(id); // if (appUser == null) // { // return HttpNotFound(); // } // return View(appUser); //} //// POST: AppUsers/Delete/5 //[HttpPost, ActionName("Delete")] //[ValidateAntiForgeryToken] //public ActionResult DeleteConfirmed(Guid id) //{ // AppUser appUser = db.AppUsers.Find(id); // db.AppUsers.Remove(appUser); // db.SaveChanges(); // return RedirectToAction("Index"); //} // GET: AppUsers/Profile/5 public ActionResult UserProfile() { string errorMessage = "Your current user appears to be corrupt, please contact your system administrator."; Guid id = AppUserHelpers.GetAppUserIdFromUser(User); if (id == null) { return(RedirectToAction("Error", "Home", new { errorMessage = errorMessage })); } AppUserProfileView view = AppUserViewHelpers.CreateAppUserProfileView(id); if (view == null) { return(RedirectToAction("Error", "Home", new { errorMessage = errorMessage })); } //DropDown if (view.SelectedOrganisationId == Guid.Empty) { ViewBag.OrganisationList = ControlHelpers.AllOrganisationsListDropDown(); //no selected item as nothing to select ViewBag.OrganisationSelected = false; } else { ViewBag.OrganisationList = ControlHelpers.AllOrganisationsListDropDown(view.SelectedOrganisationId.Value); //select the organisation as initial value ViewBag.OrganisationSelected = true; } return(View(view)); }
public ActionResult UserAdmin(UserAdminView model) { if (Request.Form["resetbutton"] != null) { return(RedirectToAction("UserAdmin")); } if (ModelState.IsValid) { if (Request.Form["savebutton"] != null) { AppUserHelpers.UpdateAppUsers(db, model.UserAdminActiveView, true, User); return(RedirectToAction("Dashboard", "Home")); } if (Request.Form["addusersbutton"] != null) { AppUserHelpers.UpdateAppUsers(db, model.UserAdminActiveView, true, User); return(RedirectToAction("AddUser")); } if (Request.Form["saveinactivebutton"] != null) { AppUserHelpers.UpdateAppUsers(db, model.UserAdminNonActiveView, false, User); return(RedirectToAction("Dashboard", "Home")); } return(RedirectToAction("Dashboard", "Home")); } return(View(model)); }
public async Task <ActionResult> AddUser([Bind(Include = "FirstName,LastName,LoginEmail,LoginPassword,ConfirmPassword,PrivacyLevel,UserRole")] UserAdminAddUserView model) { if (Request.Form["resetbutton"] != null) { return(RedirectToAction("AddUser")); } if (ModelState.IsValid) { //Create a new AppUser AppUser appUser = AppUserHelpers.CreateAppUser(db, model, User); var user = new ApplicationUser { UserName = model.LoginEmail, Email = model.LoginEmail, AppUserId = appUser.AppUserId, CurrentUserRole = appUser.UserRole }; var result = await UserManager.CreateAsync(user, model.LoginPassword); if (result.Succeeded) { if (Request.Form["adduserbutton"] != null) { return(RedirectToAction("AddUser")); } return(RedirectToAction("UserAdmin")); } //Delete the appUser account as this has not gone through AppUserHelpers.DeleteAppUser(db, appUser.AppUserId); AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult UserAdmin() { List <UserAdminView> userAdminViewForUser = UserAdminHelpers.GetUserAdminViewListForUser(User); ViewBag.CurrentUserId = AppUserHelpers.GetAppUser(User).AppUserId; //TempData["OriginalModel"] = userAdminViewForUser; return(View(userAdminViewForUser)); }
public ActionResult Tasks() { AppUser appUser = AppUserHelpers.GetAppUser(User); List <UserTaskView> userTasksForUserView = UserTaskViewHelpers.GetUserTasksForUserView(appUser.AppUserId); return(View(userTasksForUserView)); }
public async Task <ActionResult> Create(AppUserView model) { if (ModelState.IsValid) { //initialise the task creation flags bool createUserOnHoldTask = false; //Retrieve Branch Branch branch = BranchHelpers.GetBranch(db, model.SelectedBranchId.Value); //Create a new AppUser then write here AppUser appUser = AppUserHelpers.CreateAppUser(model.FirstName, model.LastName, branch.BranchId, model.EntityStatus, model.Email, model.PrivacyLevel, model.UserRole); BranchUser branchUser = null; var user = new ApplicationUser { UserName = model.Email, Email = model.Email, AppUserId = appUser.AppUserId, FullName = model.FirstName + " " + model.LastName, CurrentUserRole = model.UserRole }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { //set on-hold task flag if (model.EntityStatus == EntityStatusEnum.OnHold) { createUserOnHoldTask = true; } //Now Update related entities //BranchUser - set the status as ACTIVE as the link is active even though the entities linked are not. branchUser = BranchUserHelpers.CreateBranchUser(appUser.AppUserId, branch.BranchId, branch.CompanyId, model.UserRole, EntityStatusEnum.Active); //Task creation if (createUserOnHoldTask) { UserTaskHelpers.CreateUserTask(TaskTypeEnum.UserOnHold, "New user on hold, awaiting administrator/manager activation", appUser.AppUserId, appUser.AppUserId, EntityStatusEnum.Active); } return(RedirectToAction("UserAdmin", "Admin")); } //Delete the appUser account as this has not gone through AppUserHelpers.DeleteAppUser(appUser.AppUserId); AddErrors(result); } // If we got this far, something failed, redisplay form - set up the drop downs dependant on what was there originally from the model Branch userBranch = BranchHelpers.GetCurrentBranchForUser(AppUserHelpers.GetGuidFromUserGetAppUserId(User.Identity.GetAppUserId())); //DropDown ViewBag.BranchList = ControlHelpers.AllBranchesForCompanyListDropDown(userBranch.CompanyId, userBranch.BranchId); ViewBag.UserRoleList = ControlHelpers.UserRoleEnumListDropDown(); ViewBag.EntityStatusList = ControlHelpers.EntityStatusEnumListDropDown(); return(View(model)); }
// GET: AppUsers/Create public ActionResult Create() { Branch userBranch = BranchHelpers.GetCurrentBranchForUser(AppUserHelpers.GetGuidFromUserGetAppUserId(User.Identity.GetAppUserId())); //DropDowns ViewBag.BranchList = ControlHelpers.AllBranchesForCompanyListDropDown(userBranch.CompanyId, userBranch.BranchId); ViewBag.UserRoleList = ControlHelpers.UserRoleEnumListDropDown(); ViewBag.EntityStatusList = ControlHelpers.EntityStatusEnumListDropDown(); return(View()); }
public ActionResult ProcessButton(string buttonName) { string[] keys = buttonName.Split(':'); string buttonType = keys[0]; string buttonLevel = keys[1]; Guid ofReferenceId = Guid.Empty; Guid byAppUserId = Guid.Empty; Guid.TryParse(keys[2], out ofReferenceId); Guid.TryParse(keys[3], out byAppUserId); Guid byReferenceId = Guid.Empty; LevelEnum levelEnum = LevelEnum.User; //Set the byReference to be either the user, the user's branch or the user's company depending on level switch (buttonLevel) { case "company": levelEnum = LevelEnum.Company; byReferenceId = CompanyHelpers.GetCompanyForUser(byAppUserId).CompanyId; break; case "branch": levelEnum = LevelEnum.Branch; byReferenceId = AppUserHelpers.GetAppUser(byAppUserId).CurrentBranchId; break; case "user": levelEnum = LevelEnum.User; byReferenceId = byAppUserId; break; } switch (buttonType) { case "block": BlockHelpers.CreateBlock(levelEnum, ofReferenceId, byReferenceId, byAppUserId); break; case "friend": FriendHelpers.CreateFriend(levelEnum, ofReferenceId, byReferenceId, byAppUserId); break; case "group": //Need to go to Group screen to select a group or allow adding of a new group return(RedirectToAction("Create", "Groups", new { level = levelEnum, ofReferenceId = ofReferenceId, byReferenceId = byReferenceId, appUserid = byAppUserId })); } return(Json(new { success = true })); }
Login(LoginViewModel model, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout : false); switch (result) { case SignInStatus.Success: ApplicationUser user = UserManager.FindByEmail(model.Email); //validate user status - if not active then give appropriate message and reject - NOTE "Awaiting organisation details" is fine to go through as it allows the logged in user to add details EntityStatusEnum appUserStatus = AppUserHelpers.GetAppUserEntityStatus(user); switch (appUserStatus) { case EntityStatusEnum.OnHold: ModelState.AddModelError("", "This user is currently on hold. You will need to contact your account administrator to active your account."); AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); return(View(model)); case EntityStatusEnum.Inactive: ModelState.AddModelError("", "This user is currently inactive. You will need to re-register or contact your account administrator."); AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); return(View(model)); case EntityStatusEnum.Rejected: ModelState.AddModelError("", "This user is currently rejected. You will need to contact your account administrator to active your account."); AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); return(View(model)); case EntityStatusEnum.PasswordResetRequired: return(RedirectToAction("ChangePassword", "Manage")); } return(RedirectToLocal(returnUrl)); case SignInStatus.LockedOut: return(View("Lockout")); case SignInStatus.RequiresVerification: return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe })); case SignInStatus.Failure: default: ModelState.AddModelError("", "Invalid login attempt."); return(View(model)); } }
public async Task <ActionResult> Login(LoginViewModel model, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout : false); switch (result) { case SignInStatus.Success: ApplicationUser user = UserManager.FindByEmail(model.Email); //validate the user is not on-hold if (!AppUserHelpers.IsAppUserActive(user)) { EntityStatusEnum appUserStatus = AppUserHelpers.GetAppUserEntityStatus(user); switch (appUserStatus) { case EntityStatusEnum.Inactive: ModelState.AddModelError("", "This user is currently inactive. You will need to re-register or contact your account administrator"); break; case EntityStatusEnum.OnHold: ModelState.AddModelError("", "This user is currently on hold. You will need to contact your account administrator to active your account"); break; } AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); return(View(model)); } else { return(RedirectToAction("Index", "Home")); } case SignInStatus.LockedOut: return(View("Lockout")); case SignInStatus.RequiresVerification: return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe })); case SignInStatus.Failure: default: ModelState.AddModelError("", "Invalid login attempt."); return(View(model)); } }
public ActionResult Settings([Bind(Include = "AppUserId,MaxDistanceFilter,MaxAgeFilter,SelectionLevelFilter")] AppUserSettingsView view) { if (Request.Form["resetbutton"] != null) { return(RedirectToAction("Settings")); } if (ModelState.IsValid) { AppUserHelpers.UpdateAppUser(db, view, User); return(RedirectToAction("Index", "Home")); } return(View(view)); }
// GET: AppUsers/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } string callingController = "Home"; string callingAction = "Index"; try { string[] callingUrlSegments = Request.UrlReferrer.Segments.Select(x => x.TrimEnd('/')).ToArray(); callingController = callingUrlSegments[callingUrlSegments.Count() - 2]; callingAction = callingUrlSegments[callingUrlSegments.Count() - 1]; } catch { } AppUserEditView model = AppUserEditViewHelpers.GetAppUserEditViewForUser(db, User); model.CallingAction = callingAction; model.CallingController = callingController; Branch userBranch = BranchHelpers.GetCurrentBranchForUser(AppUserHelpers.GetGuidFromUserGetAppUserId(User.Identity.GetAppUserId())); //DropDowns ViewBag.BranchList = ControlHelpers.AllBranchesForCompanyListDropDown(userBranch.CompanyId, userBranch.BranchId); ViewBag.UserRoleList = ControlHelpers.UserRoleEnumListDropDown(); ViewBag.EntityStatusList = ControlHelpers.EntityStatusEnumListDropDown(); //Counters ViewBag.UserFriendCount = model.UserFriendListView.Count(); ViewBag.UserBranchFriendCount = model.UserBranchFriendListView.Count(); ViewBag.UserCompanyFriendCount = model.UserCompanyFriendListView.Count(); ViewBag.UserBlockCount = model.UserBlockListView.Count(); ViewBag.UserBranchBlockCount = model.UserBranchBlockListView.Count(); ViewBag.UserCompanyBlockCount = model.UserCompanyBlockListView.Count(); if (model == null) { return(HttpNotFound()); } return(View(model)); }
// GET: AppUsers/Settings/5 public ActionResult Settings() { string errorMessage = "Your current user appears to be corrupt, please contact your system administrator."; Guid id = AppUserHelpers.GetAppUserIdFromUser(User); if (id == null) { return(RedirectToAction("Error", "Home", new { errorMessage = errorMessage })); } AppUserSettingsView view = AppUserViewHelpers.CreateAppUserSettingsView(id); if (view == null) { return(RedirectToAction("Error", "Home", new { errorMessage = errorMessage })); } return(View(view)); }
public async Task <ActionResult> ChangePassword(ChangePasswordViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword, model.NewPassword); if (result.Succeeded) { var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); if (user != null) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); } AppUserHelpers.UpdateAppUserEntityStatusIfForcedPasswordChange(AppUserHelpers.GetAppUserIdFromUser(User), User); return(RedirectToAction("Index", "Home")); } AddErrors(result); return(View(model)); }
public ActionResult CancelTask(Guid?userTaskId) { if (userTaskId.HasValue) { UserTask userTask = UserTasksHelpers.GetUserTask(db, userTaskId.Value); switch (userTask.TaskType) { case TaskTypeEnum.UserOnHold: //Make AppUser inactive AppUserHelpers.UpdateAppUserEntityStatus(db, userTask.ReferenceKey, EntityStatusEnum.Inactive, User); break; } //close the Task UserTasksHelpers.UpdateEntityStatus(db, userTask.UserTaskId, EntityStatusEnum.Closed); return(Json(new { success = true })); } else { return(Json(new { success = false })); } }
// GET: Groups public ActionResult Index() { GroupEditView model = GroupViewHelpers.GetGroupEditViewForUser(db, AppUserHelpers.GetAppUserIdFromUser(User)); return(View(model)); //This view will do everything. //List all groups you belong to //List all your 'friends' groups //List the 'requests' to join your group for approval //Allow you to 'add' a new group //Allow you to remove 'your' group (you are group admin) //Allow you to 'request' a friend join your group (on them saying yes it automatically adds them) //Allow you to 'join' a friends group (on them saying yes it automatically adds you) //PS Need to add the 'friend request' stuff also. - i.e. //Friend table that holds type (User, branch, company) and Id. //- on company admin it will show company friends and give 'admin' the ability to add/remove etc.. //- on branch admin it will show branch friends and give 'admin' & 'manager' the ability to add/remove etc. //- on user it will show user friends and give all ability to add/remove etc.. //.....therefore 'add friend' on listings page highlighting company/branch/user need to be displayed for those with right access. //.....this will then go off for approval }
public ActionResult Edit([Bind(Include = "ListingId,ItemDescription,ItemType,QuantityRequired,QuantityFulfilled,QuantityOutstanding,UoM,RequiredFrom,RequiredTo,AcceptDamagedItems,AcceptOutOfDateItems,CollectionAvailable,ListingStatus,SelectedCampaignId,CampaignName,CampaignStrapLine,CampaignDescription,CampaignStartDateTime,CampaignEndDateTime")] RequirementListingEditView requirementListing) { if (ModelState.IsValid) { //If the 'Submit' button pressed then update tables, else leave as are so that on reload it takes original values once again. if (Request.Form["submitbutton"] != null) { //Update tables RequirementListingHelpers.UpdateRequirementListingFromRequirementListingEditView(db, requirementListing); return(RedirectToAction("Requirements", "ManageListings")); } return(RedirectToAction("Edit")); } //rebuild the missing details before returning to screen to show errors RequirementListing listing = RequirementListingHelpers.GetRequirementListing(db, requirementListing.ListingId); requirementListing.ListingAppUser = AppUserHelpers.GetAppUser(db, listing.ListingOriginatorAppUserId); requirementListing.ListingBranchDetails = BranchHelpers.GetBranch(db, listing.ListingOriginatorAppUserId); //Rebuild campaign details as changing will change ID but no address details, so force the change now: if (requirementListing.SelectedCampaignId != null) { Campaign campaign = CampaignHelpers.GetCampaign(db, requirementListing.SelectedCampaignId.Value); requirementListing.CampaignName = campaign.Name; requirementListing.CampaignStrapLine = campaign.StrapLine; requirementListing.CampaignDescription = campaign.Description; requirementListing.CampaignStartDateTime = campaign.CampaignStartDateTime; requirementListing.CampaignEndDateTime = campaign.CampaignEndDateTime; } ViewBag.CampaignList = ControlHelpers.AllActiveCampaignsForUserListDropDown(AppUserHelpers.GetAppUserIdFromUser(User), requirementListing.SelectedCampaignId); return(View(requirementListing)); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { //Create a new AppUser AppUser appUser = AppUserHelpers.CreateAppUser(model, User, UserRoleEnum.User); var user = new ApplicationUser { UserName = model.Email, Email = model.Email, AppUserId = appUser.AppUserId, CurrentUserRole = appUser.UserRole }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Home")); } else { //Delete the appUser account as this has not gone through AppUserHelpers.DeleteAppUser(appUser.AppUserId); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult Edit([Bind(Include = "ListingId,ItemDescription,ItemType,QuantityRequired,QuantityFulfilled,QuantityOutstanding,UoM,AvailableFrom,AvailableTo,ItemCondition,DisplayUntilDate,SellByDate,UseByDate,DeliveryAvailable,ListingStatus")] AvailableListingEditView availableListing) { if (ModelState.IsValid) { //If the 'Submit' button pressed then update tables, else leave as are so that on reload it takes original values once again. if (Request.Form["submitbutton"] != null) { //Update tables AvailableListingHelpers.UpdateAvailableListingFromAvailableListingEditView(db, availableListing); return(RedirectToAction("Available", "ManageListings")); } return(RedirectToAction("Edit")); } //rebuild the missing details before returning to screen to show errors AvailableListing listing = AvailableListingHelpers.GetAvailableListing(db, availableListing.ListingId); availableListing.ListingAppUser = AppUserHelpers.GetAppUser(db, listing.ListingOriginatorAppUserId); availableListing.ListingBranchDetails = BranchHelpers.GetBranch(db, listing.ListingOriginatorAppUserId); return(View(availableListing)); }
public ActionResult Edit([Bind(Include = "CampaignId,Name,StrapLine,Description,Image,ImageLocation,Website,CampaignStartDateTime,CampaignEndDateTime,LocationName,LocationAddressLine1,LocationAddressLine2,LocationAddressLine3,LocationAddressTownCity,LocationAddressCounty,LocationAddressPostcode,LocationTelephoneNumber,LocationEmail,LocationContactName,EntityStatus")] CampaignEditView campaign) { if (ModelState.IsValid) { //If the 'Submit' button pressed then update tables, else leave as are so that on reload it takes original values once again. if (Request.Form["submitbutton"] != null) { //Update tables CampaignHelpers.UpdateCampaignFromCampaignEditView(db, campaign); return(RedirectToAction("Campaigns", "ManageListings")); } return(RedirectToAction("Edit")); } //rebuild the missing details before returning to screen to show errors Campaign campaignDetails = CampaignHelpers.GetCampaign(db, campaign.CampaignId); campaign.CampaignAppUser = AppUserHelpers.GetAppUser(db, campaignDetails.CampaignOriginatorAppUserId); campaign.CampaignBranchDetails = BranchHelpers.GetBranch(db, campaignDetails.CampaignOriginatorBranchId); return(View(campaign)); }
public ActionResult UserProfile([Bind(Include = "AppUserId,FirstName,LastName,EntityStatus,LoginEmail,PrivacyLevel,UserRole,SelectedOrganisationId,OrganisationName,BusinessType,AddressLine1,AddressLine2,AddressLine3,AddressTownCity,AddressCounty,AddressPostcode")] AppUserProfileView view) { if (Request.Form["resetbutton"] != null) { return(RedirectToAction("UserProfile")); } if (ModelState.IsValid) { //if selectedorganisationid is null then the organisation already exists so set that flag as a limited number of fields needs updating if (view.SelectedOrganisationId == null) { AppUserHelpers.UpdateAppUser(db, view, User, true); } else { AppUserHelpers.UpdateAppUser(db, view, User, false); } return(RedirectToAction("Dashboard", "Home")); } return(View(view)); }
// GET: Task public ActionResult Details(Guid?userTaskId) { if (userTaskId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ApplicationDbContext db = new ApplicationDbContext(); //Get current user for building the Usertaskview of selected record AppUser appUser = AppUserHelpers.GetAppUser(db, User); //Get UserTaskView of selected UserTask record UserTaskView userTaskView = null; UserTaskFullView userTaskFullView = new UserTaskFullView() { UserTaskView = userTaskView }; try //try helps with issues, if no records for example then we are left with null userTaskView instead of error { userTaskView = UserTaskViewHelpers.GetUserTaskForUserView(db, appUser.AppUserId, userTaskId.Value); //Get the requestor appuser details and branch details AppUser createdByAppUser = AppUserHelpers.GetAppUser(userTaskView.CreatedBy.AppUserId); Branch createdByAppUserCurrentBranch = BranchHelpers.GetCurrentBranchForUser(db, userTaskView.CreatedBy.AppUserId); //If this is a on-hold user then get the current user role BranchUser branchUser = null; if (userTaskView.AppUserReference != null) { branchUser = BranchUserHelpers.GetBranchUser(db, userTaskView.AppUserReference.AppUserId, userTaskView.AppUserReference.CurrentBranchId); } //Build the view model userTaskFullView = new UserTaskFullView(); userTaskFullView.UserTaskView = userTaskView; if (branchUser != null) { userTaskFullView.BranchUserUserRole = branchUser.UserRole; } userTaskFullView.CreatedByAppUser = createdByAppUser; userTaskFullView.CreatedByAppUserCurrentBranch = createdByAppUserCurrentBranch; if (userTaskView.AppUserReference != null) { ViewBag.EntityStatusUserRole = EnumHelpers.GetDescription((EntityStatusEnum)userTaskFullView.UserTaskView.AppUserReference.EntityStatus); } else { ViewBag.EntityStatusUserRole = ""; } if (userTaskView.BranchReference != null) { ViewBag.EntityStatusBranchStatus = EnumHelpers.GetDescription((EntityStatusEnum)userTaskFullView.UserTaskView.BranchReference.EntityStatus); } else { ViewBag.EntityStatusBranchStatus = ""; } ViewBag.EntityStatusCreatedByUserRole = EnumHelpers.GetDescription((EntityStatusEnum)userTaskFullView.CreatedByAppUser.EntityStatus); ViewBag.EntityStatusCreatedByUserBranchStatus = EnumHelpers.GetDescription((EntityStatusEnum)userTaskFullView.CreatedByAppUserCurrentBranch.EntityStatus); ViewBag.UserTaskUserRole = EnumHelpers.GetDescription((UserRoleEnum)branchUser.UserRole); } catch { } return(View(userTaskFullView)); }
// GET: RequirementListings/Edit/5 public ActionResult Edit(Guid?id, bool showHistory) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RequirementListingEditView requirementListing = RequirementListingEditHelpers.GetRequirementListingEditView(db, id.Value, User); if (requirementListing == null) { return(HttpNotFound()); } ViewBag.CampaignList = ControlHelpers.AllActiveCampaignsForUserListDropDown(AppUserHelpers.GetAppUserIdFromUser(User), requirementListing.SelectedCampaignId); ViewBag.ShowHistory = showHistory; return(View(requirementListing)); }
public ActionResult Create([Bind(Include = "ItemDescription,ItemType,QuantityRequired,QuantityFulfilled,QuantityOutstanding,UoM,RequiredFrom,RequiredTo,AcceptDamagedItems,AcceptOutOfDateItems,CollectionAvailable,ListingStatus,SelectedCampaignId,CallingAction,CallingController")] RequirementListingAddView requirementListing) { if (ModelState.IsValid) { RequirementListingHelpers.CreateRequirementListingFromRequirementListingAddView(db, requirementListing, User); return(RedirectToAction(requirementListing.CallingAction, requirementListing.CallingController)); } ViewBag.CampaignList = ControlHelpers.AllActiveCampaignsForUserListDropDown(AppUserHelpers.GetAppUserIdFromUser(User), null); return(View(requirementListing)); }