Beispiel #1
0
        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));
        }
Beispiel #2
0
        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 }));
            }
        }
Beispiel #3
0
        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));
        }
        public ActionResult Create([Bind(Include = "BranchId,CompanyId,BranchName,BusinessType,AddressLine1,AddressLine2,AddressLine3,AddressTownCity,AddressCounty,AddressPostcode,TelephoneNumber,Email,ContactName,EntityStatus")] Branch branch)
        {
            if (ModelState.IsValid)
            {
                BranchHelpers.CreateBranch(branch);
                return(RedirectToAction("BranchAdmin", "Admin"));
            }

            return(View(branch));
        }
Beispiel #5
0
        // 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());
        }
Beispiel #6
0
        public ActionResult GetBranchAddressDetailsForBranch(Guid branchId)
        {
            if (branchId != null)
            {
                Branch branchDetails = BranchHelpers.GetBranch(branchId);

                if (branchDetails != null)
                {
                    string branchBusinessType = EnumHelpers.GetDescription(branchDetails.BusinessType);

                    return(Json(new { branchDetails, branchBusinessType, success = true }));
                }
                return(Json(new { success = false }));
            }
            return(Json(new { success = false }));
        }
Beispiel #7
0
        // 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));
        }
        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 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));
        }
Beispiel #10
0
        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));
        }
Beispiel #11
0
        // 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));
        }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                //If this is a new user and company then set to ACTIVE and an ADMIN role, else set to ON-HOLD and USER role and await activating by admin for branch/company of user and/or new branch details.
                EntityStatusEnum statusForUser   = EntityStatusEnum.Active;
                UserRoleEnum     userRoleForUser = UserRoleEnum.Admin;

                //initialise the task creation flags
                bool createUserOnHoldTask   = false;
                bool createBranchOnHoldTask = false;

                if (model.SelectedCompanyId.HasValue)
                {
                    statusForUser   = EntityStatusEnum.OnHold;
                    userRoleForUser = UserRoleEnum.User;
                }

                //Create a new AppUser then write here
                AppUser appUser = AppUserHelpers.CreateAppUser(model.FirstName, model.LastName, Guid.Empty, statusForUser, model.Email, PrivacyLevelEnum.None, userRoleForUser);

                Company    company    = null;
                Branch     branch     = null;
                BranchUser branchUser = null;

                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email, AppUserId = appUser.AppUserId, FullName = model.FirstName + " " + model.LastName, CurrentUserRole = userRoleForUser
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    //only log in if this user is not set to on-hold
                    if (!model.SelectedCompanyId.HasValue)
                    {
                        await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);
                    }
                    else  //we will need to create a task for the branch
                    {
                        createUserOnHoldTask = true;
                    }

                    //Now Update related entities
                    //Company
                    bool createCompany = true;

                    if (model.SelectedCompanyId.HasValue)
                    {
                        if (model.SelectedCompanyId.Value != Guid.Empty)
                        {
                            createCompany = false;
                        }
                    }

                    if (createCompany)
                    {
                        company = CompanyHelpers.CreateCompany(Guid.Empty, model.CompanyName, model.CompanyRegistrationDetails, model.CharityRegistrationDetails, model.VATRegistrationDetails, model.AllowBranchTrading, PrivacyLevelEnum.None, statusForUser);
                    }
                    else
                    {
                        company = CompanyHelpers.GetCompany(model.SelectedCompanyId.Value);
                    }


                    //Branch
                    bool createBranch = true;

                    if (model.SelectedBranchId.HasValue)
                    {
                        if (model.SelectedBranchId.Value != Guid.Empty)
                        {
                            createBranch = false;
                        }
                    }

                    if (createBranch)
                    {
                        string branchName = model.BranchName;
                        if (!model.SelectedCompanyId.HasValue)
                        {
                            branchName = "Head Office";
                        }

                        if (createCompany) //use details stored against company part of model
                        {
                            branch = BranchHelpers.CreateBranch(company.CompanyId, model.CompanyBusinessType.Value, branchName, model.CompanyAddressLine1, model.CompanyAddressLine2, model.CompanyAddressLine3, model.CompanyAddressTownCity, model.CompanyAddressCounty, model.CompanyAddressPostcode, model.CompanyTelephoneNumber, model.CompanyEmail, model.CompanyContactName, company.PrivacyLevel, statusForUser);
                        }
                        else
                        {
                            //set last addAdminUsers flag to true as this is a new branch on an existing company so all Admin users need to be associated with this branch
                            branch = BranchHelpers.CreateBranch(company.CompanyId, model.BranchBusinessType.Value, branchName, model.BranchAddressLine1, model.BranchAddressLine2, model.BranchAddressLine3, model.BranchAddressTownCity, model.BranchAddressCounty, model.BranchAddressPostcode, model.BranchTelephoneNumber, model.BranchEmail, model.BranchContactName, company.PrivacyLevel, statusForUser);
                            createBranchOnHoldTask = true;
                        }

                        //Company - set head office branch as the newly created branch for this new company (defaults to 'Head Office')
                        if (!model.SelectedCompanyId.HasValue)
                        {
                            company = CompanyHelpers.UpdateCompanyHeadOffice(company.CompanyId, branch.BranchId);
                        }
                    }
                    else
                    {
                        branch = BranchHelpers.GetBranch(model.SelectedBranchId.Value);
                    }

                    //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, company.CompanyId, userRoleForUser, EntityStatusEnum.Active);

                    //if addAdminUsersToThisBranch is true then add all admin users for the company to this branch
                    BranchUserHelpers.CreateBranchAdminUsersForNewBranch(branch, userRoleForUser);

                    //Update AppUser with the branch we are adding/using to set as current branch for new user
                    appUser = AppUserHelpers.UpdateCurrentBranchId(appUser.AppUserId, branch.BranchId);

                    // 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>");

                    //Task creation
                    if (createUserOnHoldTask)
                    {
                        UserTaskHelpers.CreateUserTask(TaskTypeEnum.UserOnHold, "New user on hold, awaiting administrator/manager activation", appUser.AppUserId, appUser.AppUserId, EntityStatusEnum.Active);
                    }

                    if (createBranchOnHoldTask)
                    {
                        UserTaskHelpers.CreateUserTask(TaskTypeEnum.BranchOnHold, "New branch on hold, awaiting administrator activation", branch.BranchId, appUser.AppUserId, EntityStatusEnum.Active);
                    }


                    if (model.SelectedCompanyId.HasValue)
                    {
                        return(RedirectToAction("Confirmation"));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }

                //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
            if (model.SelectedCompanyId.HasValue)
            {
                ViewBag.CompanyList = ControlHelpers.AllCompaniesListDropDown(model.SelectedCompanyId.Value);
                if (model.SelectedBranchId.HasValue)
                {
                    ViewBag.BranchList = ControlHelpers.AllBranchesForCompanyListDropDown(model.SelectedCompanyId.Value, model.SelectedBranchId.Value);
                }
                else
                {
                    ViewBag.BranchList = new SelectList(Enumerable.Empty <SelectListItem>(), "BranchId", "BranchName");
                }
            }
            else
            {
                ViewBag.CompanyList = ControlHelpers.AllCompaniesListDropDown();
                ViewBag.BranchList  = new SelectList(Enumerable.Empty <SelectListItem>(), "BranchId", "BranchName");
            }

            ViewBag.BusinessTypeList = ControlHelpers.BusinessTypeEnumListDropDown();

            return(View(model));
        }
Beispiel #13
0
        public ActionResult OtherAdminUsersExistForCompany(Guid appUserId, Guid branchId)
        {
            List <BranchUser> branchUsers = BranchUserHelpers.GetAdminBranchUsersForBranchExcludingUser(branchId, appUserId);
            BranchUser        branchUserForCallingUser = BranchUserHelpers.GetBranchUser(appUserId, branchId, BranchHelpers.GetBranch(branchId).CompanyId);

            //Add 1 to the selected item as there is a blank option at the start
            string originalSelectedItem = ((int)branchUserForCallingUser.UserRole + 1).ToString();

            if (branchUsers == null || branchUsers.Count == 0)
            {
                return(Json(new { success = false, originalRole = originalSelectedItem }));
            }
            else
            {
                return(Json(new { success = true, originalRole = originalSelectedItem }));
            }
        }