public ActionResult Edit(int id = 0)
        {
            try
            {
                sw.Organisation organisation = swdb.Organisation.Single(o => o.Id == id);
                if (organisation == null)
                {
                    return(HttpNotFound());
                }

                OrganisationEditModel editModel = new OrganisationEditModel();
                editModel.orgTypes = new SelectList(swdb.OrganisationType, "Id", "Name", organisation.OrganisationTypeId).ToList();
                // editModel.OfficeBranch = new SelectList(db.OfficeBranch, "Id", "BranchName", organisation.BranchID).ToList();
                editModel.org = organisation;
                //editModel.accountTypes = db.AccountType.ToList();
                //editModel.SelectedAcountTypes = db.OrganisationPortfolio.Where(x => x.OrgID == organisation.Id).Select(x => x.AccountTypeID ?? 0).ToArray();

                return(View(editModel));
            }
            catch (Exception ex)
            {
                // Log with Elmah
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", "Home", new { area = "Admin" }));
            }
        }
        public ActionResult Create(int orgID)
        {
            try
            {
                OrganisationAddressModel editModel = new OrganisationAddressModel();
                sw.Organisation          member    = swdb.Organisation.Where(x => x.Id == orgID).FirstOrDefault();

                if (member == null)
                {
                    return(HttpNotFound());
                }

                sw.AddressBook memberBeneficiary = new sw.AddressBook()
                {
                    OrgID = member.Id
                };
                editModel.org         = member;
                editModel.addressBook = memberBeneficiary;
                editModel.addressType = new SelectList(swdb.AddressType, "ID", "Name").ToList();

                return(View(editModel));
            }
            catch (Exception ex)
            {
                // Log with Elmah
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", new { orgID = orgID }));
            }
        }
        public ActionResult Create(OrganisationAddressModel editModel)
        {
            sw.AddressBook memberBeneficiary = editModel.addressBook;
            try
            {
                if (ModelState.IsValid)
                {
                    memberBeneficiary.ModifiedBy  = User.Identity.Name;
                    memberBeneficiary.ModifedDate = DateTime.Now;
                    swdb.AddressBook.Add(memberBeneficiary);

                    swdb.SaveChanges();
                    TempData["message"] = "<b>" + memberBeneficiary.Street + "</b> was Successfully Saved";
                    return(RedirectToAction("Index", new { orgID = memberBeneficiary.OrgID }));
                }
                sw.Organisation member = swdb.Organisation.Where(x => x.Id == editModel.addressBook.OrgID).FirstOrDefault();
                editModel.org         = member;
                editModel.addressType = new SelectList(swdb.AddressType, "ID", "Name").ToList();
                return(View(editModel));
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", new { orgID = memberBeneficiary.OrgID }));
            }
        }
        public ActionResult Edit(int ID)
        {
            try
            {
                OrganisationContactModel editModel         = new OrganisationContactModel();
                sw.ContactInfo           memberBeneficiary = swdb.ContactInfo.Where(x => x.Id == ID).FirstOrDefault();

                if (memberBeneficiary == null)
                {
                    return(HttpNotFound());
                }

                sw.Organisation member = swdb.Organisation.Where(x => x.Id == memberBeneficiary.OrgID).FirstOrDefault();

                editModel.org         = member;
                editModel.contactInfo = memberBeneficiary;

                return(View(editModel));
            }
            catch (Exception ex)
            {
                // Log with Elmah
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", "Home", new { area = "Admin" }));
            }
        }
示例#5
0
 public sw.Organisation byUser(MembershipUser user)
 {
     sw.Organisation organisation = (from u in swdb.Users
                                     where u.UserId == (Guid)user.ProviderUserKey
                                     select u.Organisation.FirstOrDefault()).FirstOrDefault();
     return(organisation);
 }
示例#6
0
        public ActionResult Index()
        {
            try
            {
                if (System.Web.Security.Roles.IsUserInRole("Organisation Admin"))
                {
                    //find the bank/organisation code by the user identity
                    var user = swdb.Users.Where(x => x.UserName.ToUpper() == User.Identity.Name.ToUpper()).FirstOrDefault();
                    if (user == null)
                    {
                        throw new Exception("User Account Details can not be found");
                    }

                    sw.Organisation organisation = user.Organisation.FirstOrDefault();
                    if (organisation == null)
                    {
                        throw new Exception("Organisation Details can not be found");
                    }
                    ViewBag.OrganisationName = organisation.Name;
                }//ProcessUtility service = new ProcessUtility();
                 //List<string> numbers = new List<string>();
                 //service.SendSMSToPersons()

                DashboardViewModel viewModel = new DashboardViewModel();
                if (Session["TotalEmployers"] == null)
                {
                    Session["TotalEmployers"] = swdb.Organisation.Where(x => x.StatusID != 2).Count().ToString();
                    viewModel.TotalEmployers  = Session["TotalEmployers"].ToString();
                }
                else
                {
                    viewModel.TotalEmployers = Session["TotalEmployers"].ToString();
                }



                //form monthly



                //Weekly dashboard

                DateTime lastweek = DateTime.Now.AddDays(-7);


                //daily dashboard



                return(View(viewModel));
            }
            catch (Exception ex)
            {
                TempData["message"] = "Could not process your request at this time";
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return(RedirectToAction("Index"));
            }
        }
        public ActionResult Index([DefaultValue(1)] int page, string keywords, [DefaultValue(12)] int pgsize, int orgID)
        {
            try
            {
                //var organisation = db.Organisation.Include("OrganisationType");
                //return View(organisation.ToList());

                sw.Organisation member = swdb.Organisation.Where(x => x.Id == orgID).FirstOrDefault();
                if (member == null)
                {
                    TempData["message"] = Settings.Default.GenericExceptionMessage;
                    return(RedirectToAction("Index", "Home"));
                }

                List <sw.AddressBook> rowsToShow = new List <sw.AddressBook>();
                int totalRecords = 0;


                if (!string.IsNullOrEmpty(keywords))
                {
                    rowsToShow = swdb.AddressBook.Where(x => x.OrgID == orgID && (x.City.ToUpper().Contains(keywords.Trim().ToUpper()) || x.Street.ToUpper().Contains(keywords.Trim().ToUpper()))).OrderBy(x => x.Id).Skip((page - 1) * pgsize).Take(pgsize).ToList();

                    totalRecords = swdb.AddressBook.Where(x => x.OrgID == orgID && (x.City.ToUpper().Contains(keywords.Trim().ToUpper()) || x.Street.ToUpper().Contains(keywords.Trim().ToUpper()))).Count();
                }
                else
                {
                    rowsToShow   = swdb.AddressBook.Where(x => x.OrgID == orgID).OrderBy(x => x.Id).Skip((page - 1) * pgsize).Take(pgsize).ToList();
                    totalRecords = swdb.AddressBook.Where(x => x.OrgID == orgID).Count();
                }


                OrganisationAddressModel model = new OrganisationAddressModel()
                {
                    Rows       = rowsToShow,
                    org        = member,
                    PagingInfo = new PagingInfo
                    {
                        FirstItem    = ((page - 1) * pgsize) + 1,
                        LastItem     = page * pgsize,
                        CurrentPage  = page,
                        ItemsPerPage = pgsize,
                        TotalItems   = totalRecords
                    },
                    CurrentKeywords = keywords,
                    PageSize        = pgsize
                };
                return(View(model));
            }
            catch (Exception ex)
            {
                // Log with Elmah
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", "Home", new { area = "Admin" }));
            }
        }
        //
        // GET: /Admin/Organisations/Delete/5

        //public ActionResult Delete(int id = 0)
        //{
        //    Organisation organisation = db.Organisation.Single(o => o.Id == id);
        //    if (organisation == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    return View(organisation);
        //}

        ////
        //// POST: /Admin/Organisations/Delete/5

        //[HttpPost, ActionName("Delete")]
        //public ActionResult DeleteConfirmed(int id)
        //{
        //    Organisation organisation = db.Organisation.Single(o => o.Id == id);
        //    db.Organisation.DeleteObject(organisation);
        //    db.SaveChanges();
        //    return RedirectToAction("Index");
        //}



        private int getOrgID()
        {
            sw.Organisation organisation       = new sw.Organisation();
            GetOrganisation objGetOrganisation = new GetOrganisation();
            MembershipUser  user = Membership.GetUser(User.Identity.Name);

            organisation = objGetOrganisation.byUser(user);
            if (organisation == null)
            {
                return(0);
            }
            return(organisation.Id);
        }
示例#9
0
        public ActionResult EditProfile(string UserId)
        {
            try
            {
                ProfileEditModel model = new ProfileEditModel();
                model.userDetails = new sw.UserDetails();

                // model.ncsUserDetails = new sw.NCSUserDetails();
                Guid guidUserId;
                if (string.IsNullOrEmpty(UserId))
                {
                    user       = Membership.GetUser(User.Identity.Name, false);
                    guidUserId = (Guid)user.ProviderUserKey;
                }
                else
                {
                    if (!System.Web.Security.Roles.IsUserInRole("ADMINISTRATOR") && !System.Web.Security.Roles.IsUserInRole("Organisation Admin"))
                    {
                        throw new Exception("You Do not have the privilege to perform this action");
                    }
                    guidUserId = Guid.Parse(UserId);
                    user       = Membership.GetUser(guidUserId, false);
                }

                var userDetails = (from x in swdb.UserDetails where x.UserId == guidUserId select x).ToList();
                if (userDetails.Count > 0)
                {
                    model.userDetails = userDetails.FirstOrDefault();
                }
                else
                {
                    model.userDetails.UserId = guidUserId;
                }

                GetOrganisation obj          = new GetOrganisation();
                sw.Organisation organisation = new sw.Organisation();
                organisation = obj.byUser(user);

                model.organisation = organisation;
                // model.BranchList = new SelectList(db.OfficeBranch.OrderBy(x => x.BranchName), "ID", "BranchName");
                return(View(model));
            }
            catch (Exception ex)
            {
                //ToDo: Log with Elmah
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", "Home", new { area = "Admin" }));
            }
        }
示例#10
0
        public virtual ActionResult GrantRolesToUser(string username, [DefaultValue(0)] int Id)
        {
            try
            {
                sw.Organisation organisation = new sw.Organisation();
                if (System.Web.Security.Roles.IsUserInRole(Settings.Default.OrganisationAdminRole) && !System.Web.Security.Roles.IsUserInRole("Administrator"))
                {
                    GetOrganisation objGetOrganisation = new GetOrganisation();
                    MembershipUser  user = Membership.GetUser(User.Identity.Name);
                    organisation = objGetOrganisation.byUser(user);
                    if (organisation == null)
                    {
                        throw new Exception("Could not find Organisation");
                    }
                    Id = organisation.Id;
                }
                if (string.IsNullOrEmpty(username))
                {
                    return(RedirectToAction("Index", new { Id = Id }));
                }
                GrantRolesToUserViewModel model = new GrantRolesToUserViewModel();
                model.UserName       = username;
                model.AvailableRoles = (string.IsNullOrEmpty(username) ? new SelectList(roleService.GetAllRoles()) : new SelectList(roleService.AvailableRolesForUser(username)));
                model.GrantedRoles   = (string.IsNullOrEmpty(username) ? new SelectList(new string[] { }) : new SelectList(roleService.GetRolesForUser(username)));

                if (Id != 0)
                {
                    organisation = (from o in swdb.Organisation where o.Id == Id select o).FirstOrDefault();

                    var roles = organisation.Roles.Select(x => x.RoleName).ToList();
                    model.AvailableRoles = (string.IsNullOrEmpty(username) ? new SelectList(new string[] { }) : new SelectList(roles.Except(roleService.GetRolesForUser(username))));
                }
                model.objOrganisation = organisation;
                //model.Id = Id;
                return(View(model));
            }
            catch (Exception ex)
            {
                //Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", "Home", new { area = "Admin" }));
            }
        }
示例#11
0
        public ActionResult Update(string userName, [DefaultValue(0)] int Id)
        {
            try
            {
                sw.Organisation organisation = new sw.Organisation();
                if (System.Web.Security.Roles.IsUserInRole(Settings.Default.OrganisationAdminRole) && !System.Web.Security.Roles.IsUserInRole("Administrator"))
                {
                    GetOrganisation objGetOrganisation = new GetOrganisation();
                    MembershipUser  user = Membership.GetUser(User.Identity.Name);
                    organisation = objGetOrganisation.byUser(user);
                    if (organisation == null)
                    {
                        throw new Exception("Could not find Organisation");
                    }
                    Id = organisation.Id;
                }
                if (Id != 0)
                {
                    organisation = (from o in swdb.Organisation where o.Id == Id select o).FirstOrDefault();
                    if (organisation == null)
                    {
                        throw new Exception("Could not find Organisation");
                    }
                }
                MembershipUser updateuser = membershipService.GetUser(userName);

                UserViewModel viewModel = new UserViewModel();
                viewModel.User = updateuser;
                viewModel.RequiresSecretQuestionAndAnswer = membershipService.RequiresQuestionAndAnswer;
                viewModel.Roles           = roleService.GetRolesForUser(userName);
                viewModel.objOrganisation = organisation;

                return(View(viewModel));
            }
            catch (Exception ex)
            {
                //Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", "Home", new { area = "Admin" }));
            }
        }
示例#12
0
        public virtual ActionResult CreateUser([DefaultValue(0)] int Id)
        {
            try
            {
                sw.Organisation organisation = new sw.Organisation();
                var             model        = new RegisterViewModel();

                model.RequireSecretQuestionAndAnswer = membershipService.RequiresQuestionAndAnswer;
                if (System.Web.Security.Roles.IsUserInRole(Settings.Default.OrganisationAdminRole) && !System.Web.Security.Roles.IsUserInRole("Administrator"))
                {
                    GetOrganisation objGetOrganisation = new GetOrganisation();
                    MembershipUser  user = Membership.GetUser(User.Identity.Name);
                    organisation = objGetOrganisation.byUser(user);
                    if (organisation == null)
                    {
                        throw new Exception("Could not find Organisation");
                    }
                    Id = organisation.Id;
                }
                if (Id != 0)
                {
                    organisation = (from o in swdb.Organisation where o.Id == Id select o).FirstOrDefault();
                    if (organisation == null)
                    {
                        throw new Exception("Could not find Organisation");
                    }
                    //model.OrganizationId = OrganizationId.ToString();
                }
                model.objOrganisation = organisation;
                return(View(model));
            }
            catch (Exception ex)
            {
                //ToDo: Log with Elmah
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", "Home", new { area = "Admin" }));
            }
        }
 public ActionResult Index()
 {
     try {
         MembershipUser  user         = Membership.GetUser(User.Identity.Name);
         sw.Organisation organisation = (from o in swdb.Organisation
                                         where o.Users.Select(x => x.UserId).Contains((Guid)user.ProviderUserKey)
                                         select o).FirstOrDefault();
         if (organisation == null)
         {
             throw new Exception("Could not find the organisation details");
         }
         OrganisationAdminViewModel model = new OrganisationAdminViewModel();
         model.Row      = organisation;
         model.LogoPath = Settings.Default.OrganisationLogoPath;
         return(View(model));
     }
     catch (Exception ex)
     {
         // Log with Elmah
         TempData["message"] = Settings.Default.GenericExceptionMessage;
         return(RedirectToAction("Index", "Home", new { area = "Admin" }));
     }
 }
        public ActionResult Edit(OrganisationEditModel editModel)
        {
            try
            {
                sw.Organisation organisation = editModel.org;
                if (ModelState.IsValid)
                {
                    if (String.IsNullOrEmpty(organisation.RegNumber))
                    {
                        var applNoResp = generateEmployerNumber(organisation.Name, organisation.CommencementDate ?? DateTime.Now);
                        if (applNoResp.Key == true)
                        {
                            organisation.RegNumber = applNoResp.Value;
                        }
                    }


                    organisation.ModifiedBy   = User.Identity.Name;
                    organisation.ModifiedDate = DateTime.Now;
                    swdb.Organisation.Attach(organisation);
                    swdb.Entry(organisation).State = EntityState.Modified;
                    // swdb.ObjectStateManager.ChangeObjectState(organisation, EntityState.Modified);
                    swdb.SaveChanges();



                    if (membershipService.GetUser(organisation.RegNumber) == null)
                    {
                        MembershipUser newUser;
                        //MembershipCreateStatus status;
                        newUser = membershipService.CreateUser(organisation.RegNumber, organisation.RegNumber, organisation.ContactEmailAddress);

                        roleService.AddUserToRole(organisation.RegNumber, "Organisation Admin");

                        sw.Users user = swdb.Users.Where(x => x.UserName == organisation.RegNumber).FirstOrDefault();
                        organisation.Users.Add(user);
                        swdb.SaveChanges();
                    }


                    //int[] acnts = editModel.SelectedAcountTypes;

                    //if (acnts != null)
                    //{
                    //    foreach (int account in acnts)
                    //    {
                    //        OrganisationPortfolio orgPort = db.OrganisationPortfolio.Where(x => x.OrgID == organisation.Id && x.AccountTypeID == account).FirstOrDefault();
                    //        if (orgPort == null)
                    //        {
                    //            OrganisationPortfolio detail = new OrganisationPortfolio();
                    //            detail.AccountTypeID = account;
                    //            detail.OrgID = organisation.Id;
                    //            detail.AccountState = 1;
                    //            detail.LastPayment = DateTime.Now;
                    //            detail.ModifiedBy = User.Identity.Name;
                    //            detail.ModifiedDate = DateTime.Now;
                    //            detail.TotalPayments = 0;
                    //            detail.TotalOverPaid = 0;
                    //            detail.TotalPenalty = 0;
                    //            db.OrganisationPortfolio.AddObject(detail);
                    //            db.SaveChanges();
                    //        }
                    //    }
                    //}



                    TempData["message"] = "<b>" + organisation.Name + "</b> was Successfully Updated";
                    return(RedirectToAction("Index"));
                }
                editModel.orgTypes = new SelectList(swdb.OrganisationType, "Id", "Name", organisation.OrganisationTypeId).ToList();
                //editModel.OfficeBranch = new SelectList(db.OfficeBranch, "Id", "BranchName", organisation.BranchID).ToList();
                //editModel.accountTypes = db.AccountType.ToList();
                //editModel.SelectedAcountTypes = db.OrganisationPortfolio.Where(x => x.OrgID == organisation.Id).Select(x => x.AccountTypeID ?? 0).ToArray();

                return(View(editModel));
            }
            catch (Exception ex)
            {
                // Log with Elmah
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", "Home", new { area = "Admin" }));
            }
        }
示例#15
0
        public virtual ActionResult Index(string filterby, string searchterm, [DefaultValue(1)] int page, [DefaultValue(12)] int pgsize, [DefaultValue(0)] int Id)
        {
            try
            {
                sw.Organisation      organisation = new sw.Organisation();
                ManageUsersViewModel viewModel    = new ManageUsersViewModel();
                viewModel.Users      = null;
                viewModel.FilterBy   = filterby;
                viewModel.SearchTerm = searchterm;

                if (!string.IsNullOrEmpty(filterby))
                {
                    if (filterby == "all")
                    {
                        rows = swdb.Users.ToList();
                    }
                    else if (!string.IsNullOrEmpty(searchterm))
                    {
                        string query = searchterm.Trim().ToUpper();
                        if (filterby == "email")
                        {
                            rows = (from u in swdb.Users where u.Memberships.Email.ToUpper().Contains(query) select u).ToList();
                        }
                        else if (filterby == "username")
                        {
                            rows = (from u in swdb.Users where u.UserName.ToUpper().Contains(query) select u).ToList();
                        }
                    }
                    else
                    {
                        rows = swdb.Users.ToList();
                    }
                    if (System.Web.Security.Roles.IsUserInRole(Settings.Default.OrganisationAdminRole) && !System.Web.Security.Roles.IsUserInRole("Administrator"))
                    {
                        GetOrganisation objGetOrganisation = new GetOrganisation();
                        MembershipUser  user = Membership.GetUser(User.Identity.Name);
                        organisation = objGetOrganisation.byUser(user);
                        if (organisation == null)
                        {
                            throw new Exception("Could not find Organisation");
                        }
                        Id = organisation.Id;

                        //viewModel.OrganizationId = organization.Id;
                        //Id = organization.Id;
                        //TempData["messageType"] = "alert-warning";
                        //TempData["message"] = "You are not Authorize to access all Users Account in the System";
                        //return RedirectToAction("IndexOrgAdmin", "Organization", new { area = "Setup" });
                    }
                    if (Id != 0)
                    {
                        organisation = (from o in swdb.Organisation where o.Id == Id select o).FirstOrDefault();
                        if (organisation == null)
                        {
                            throw new Exception("Could not find Organisation");
                        }
                        //viewModel.OrganizationId = OrganizationId;
                        if (!string.IsNullOrEmpty(filterby))
                        {
                            if (filterby == "all")
                            {
                                rows = organisation.Users.ToList();
                            }
                            else if (!string.IsNullOrEmpty(searchterm))
                            {
                                string query = searchterm.Trim().ToUpper();
                                if (filterby == "email")
                                {
                                    rows = organisation.Users.Where(x => x.Memberships.Email.ToUpper().Contains(query)).ToList();
                                }
                                else if (filterby == "username")
                                {
                                    rows = organisation.Users.Where(x => x.UserName.ToUpper().Contains(query)).ToList();
                                }
                            }
                            else
                            {
                                rows = organisation.Users.ToList();
                            }
                        }
                    }
                    //foreach (var username in usernames)
                    //{
                    //    rows.Add(membershipService.GetUser(username, false));
                    //}
                    viewModel.Rows = rows.Skip((page - 1) * pgsize).Take(pgsize).ToList();
                }
                viewModel.PagingInfo = new PagingInfo
                {
                    FirstItem    = ((page - 1) * pgsize) + 1,
                    LastItem     = page * pgsize,
                    CurrentPage  = page,
                    ItemsPerPage = pgsize,
                    TotalItems   = rows.Count()
                };
                viewModel.PageSize        = pgsize;
                viewModel.objOrganisation = organisation;
                return(View(viewModel));
            }
            catch (Exception ex)
            {
                //ToDo: Log with Elmah
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", "Home", new { area = "Admin" }));
            }
        }
示例#16
0
        public virtual ActionResult CreateUser(RegisterViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    sw.Organisation organisation = new sw.Organisation();
                    //var password = Membership.GeneratePassword(8, 0);
                    // model.Password = password;
                    //model.ConfirmPassword = password;
                    string                 message = "Welcome <br><br>Find below your account details<br><br>Username: "******" <br>Password: "******"New Account Details";
                    MembershipUser         newUser;
                    MembershipCreateStatus status;
                    newUser = membershipService.CreateUser(model.UserName, model.Password, model.Email, model.SecretQuestion, model.SecretAnswer, model.Approve, out status);

                    if (newUser == null)
                    {
                        var msg = GetErrorMessage(status);
                        TempData["message"] = "alert-danger";
                        TempData["message"] = msg;
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        if (System.Web.Security.Roles.IsUserInRole(Settings.Default.OrganisationAdminRole) && !System.Web.Security.Roles.IsUserInRole("Administrator"))
                        {
                            GetOrganisation objGetOrganisation = new GetOrganisation();
                            MembershipUser  user = Membership.GetUser(User.Identity.Name);
                            organisation = objGetOrganisation.byUser(user);
                            if (organisation == null)
                            {
                                throw new Exception("Could not find Organisation");
                            }
                            model.Id = organisation.Id;
                        }
                        if (model.Id != 0)
                        {
                            organisation = (from o in swdb.Organisation where o.Id == model.Id select o).FirstOrDefault();
                            if (organisation == null)
                            {
                                throw new Exception("Could not find Organisation");
                            }
                            model.objOrganisation = organisation;
                            sw.Users user = swdb.Users.Where(x => x.UserId == (Guid)newUser.ProviderUserKey).FirstOrDefault();
                            organisation.Users.Add(user);
                            swdb.SaveChanges();

                            ///Send Email to New User Account////
                            // @utility.SendEmailToPerson(Settings.Default.EmailReplyTo, newUser.Email, subject, message, DateTime.Now, null, null, null);
                            return(RedirectToAction("GrantRolesToUser", new { username = newUser.UserName, Id = model.Id }));
                        }
                        ///Send Email to New User Account////
                        // @utility.SendEmailToPerson(Settings.Default.EmailReplyTo, newUser.Email, subject, message, DateTime.Now, null, null, null);
                        return(routeHelpers.Actions.GrantRolesToUser(newUser.UserName));
                        //RedirectToAction("GrantRolesToUser",new{UserName = '', Id = ''})
                    }
                }
            }
            catch (Exception ex)
            {
                //Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", "Home", new { area = "Admin" }));
            }
            return(View());
        }