public static OrgAdminInfoModel ToOrgAdminInfoModel(this OrganizationResponse Organizations)
        {
            OrgAdminInfoModel OrgAdminInfoModel = new OrgAdminInfoModel();

            OrgAdminInfoModel.OrgName            = Organizations.OrganizationList[0].Organization;
            OrgAdminInfoModel.IsOrgEnabled       = Organizations.OrganizationList[0].IsEnabled;
            OrgAdminInfoModel.IsHostOrganization = Organizations.OrganizationList[0].IsHostOrganization;

            return(OrgAdminInfoModel);
        }
예제 #2
0
        public void TestOrgAdminInfo()
        {
            //OrganizationResponse objOrganizationResponse = new OrganizationResponse();
            OrgAdminInfoModel objOrgAdminInfoModel = new OrgAdminInfoModel();

            // int numberOfPublicPropertiesofOrganizationResponse = objOrganizationResponse.GetType().GetProperties().Count();
            int numberOfPublicPropertiesofOrgAdminInfoModel = objOrgAdminInfoModel.GetType().GetProperties().Count();

            // Assert.AreEqual(numberOfPublicPropertiesofOrganizationResponse, OrganizationResponsePropertyCount, "OrganizationResponse properties has been changed");
            Assert.AreEqual(numberOfPublicPropertiesofOrgAdminInfoModel, OrgAdminInfoModelPropertyCount, "OrgAdminInfoModel properties has been changed");
        }
예제 #3
0
        public ActionResult OrgInfo(string orgkey, bool iseditmode)
        {
            OrgAdminInfoModel OrgInfo = new OrgAdminInfoModel();
            string            version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            ViewBag.Version = version;
            if (iseditmode)
            {
                OrganizationRequest Request = new OrganizationRequest();
                Request.Organization.OrganizationKey = orgkey;

                OrganizationResponse Organizations = _isurveyFacade.GetOrganizationInfo(Request);
                OrgInfo            = Mapper.ToOrgAdminInfoModel(Organizations);
                OrgInfo.IsEditMode = iseditmode;
                return(View("OrgInfo", OrgInfo));
            }

            OrgInfo.IsEditMode   = iseditmode;
            OrgInfo.IsOrgEnabled = true;
            return(View("OrgInfo", OrgInfo));
        }
        public ActionResult OrgInfo(string orgKey, bool isEditMode)
        {
            OrgAdminInfoModel orgInfo = new OrgAdminInfoModel();
            string            version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            ViewBag.Version = version;
            if (isEditMode)
            {
                OrganizationRequest request = new OrganizationRequest();
                request.Organization.OrganizationKey = orgKey;

                OrganizationResponse organizations = _securityFacade.GetOrganizationInfo(request);
                orgInfo            = organizations.ToOrgAdminInfoModel();
                orgInfo.IsEditMode = isEditMode;
                return(View(ViewActions.OrgInfo, orgInfo));
            }

            orgInfo.IsEditMode   = isEditMode;
            orgInfo.IsOrgEnabled = true;
            return(View(ViewActions.OrgInfo, orgInfo));
        }
예제 #5
0
        public ActionResult OrgInfo(OrgAdminInfoModel OrgAdminInfoModel)
        {
            int    UserId          = SurveyHelper.GetDecryptUserId(Session["UserId"].ToString());
            int    UserHighestRole = int.Parse(Session["UserHighestRole"].ToString());
            string url             = "";

            if (this.Request.UrlReferrer == null)
            {
                url = this.Request.Url.ToString();
            }
            else
            {
                url = this.Request.UrlReferrer.ToString();
            }
            //Edit Organization
            if (OrgAdminInfoModel.IsEditMode)
            {
                ModelState.Remove("AdminFirstName");
                ModelState.Remove("AdminLastName");
                ModelState.Remove("ConfirmAdminEmail");
                ModelState.Remove("AdminEmail");



                OrganizationRequest Request = new OrganizationRequest();


                UserDTO AdminInfo = new UserDTO();

                AdminInfo.FirstName           = "";
                AdminInfo.LastName            = "";
                AdminInfo.EmailAddress        = "";
                AdminInfo.Role                = 0;
                AdminInfo.PhoneNumber         = "";
                Request.OrganizationAdminInfo = AdminInfo;


                Request.Organization.Organization = OrgAdminInfoModel.OrgName;
                Request.Organization.IsEnabled    = OrgAdminInfoModel.IsOrgEnabled;

                Request.Organization.OrganizationKey = GetOrgKey(url);
                Request.UserId   = UserId;
                Request.UserRole = UserHighestRole;
                Request.Action   = "UpDate";
                try
                {
                    OrganizationResponse     Result        = _isurveyFacade.SetOrganization(Request);
                    OrganizationResponse     Organizations = _isurveyFacade.GetUserOrganizations(Request);
                    List <OrganizationModel> Model         = Mapper.ToOrganizationModelList(Organizations.OrganizationList);
                    OrgListModel             OrgListModel  = new OrgListModel();
                    OrgListModel.OrganizationList = Model;
                    OrgListModel.Message          = "Organization " + OrgAdminInfoModel.OrgName + " has been updated.";
                    if (Result.Message.ToUpper() != "EXISTS" && Result.Message.ToUpper() != "ERROR")
                    {
                        OrgListModel.Message = "Organization " + OrgAdminInfoModel.OrgName + " has been updated.";
                        return(View("OrgList", OrgListModel));
                    }
                    else if (Result.Message.ToUpper() == "ERROR")
                    {
                        OrgAdminInfoModel OrgInfo = new OrgAdminInfoModel();
                        Request.Organization.OrganizationKey = GetOrgKey(url);;

                        Organizations      = _isurveyFacade.GetOrganizationInfo(Request);
                        OrgInfo            = Mapper.ToOrgAdminInfoModel(Organizations);
                        OrgInfo.IsEditMode = true;
                        ModelState.AddModelError("IsOrgEnabled", "Organization for the super admin cannot be deactivated.");
                        return(View("OrgInfo", OrgInfo));
                    }
                    else
                    {
                        OrgAdminInfoModel OrgInfo = new OrgAdminInfoModel();
                        Request.Organization.OrganizationKey = GetOrgKey(url);;

                        Organizations      = _isurveyFacade.GetOrganizationInfo(Request);
                        OrgInfo            = Mapper.ToOrgAdminInfoModel(Organizations);
                        OrgInfo.IsEditMode = true;
                        ModelState.AddModelError("OrgName", "The organization name provided already exists.");
                        return(View("OrgInfo", OrgInfo));
                    }
                }
                catch (Exception ex)
                {
                    return(View(OrgAdminInfoModel));
                }
            }
            else
            {
                // Add new Organization

                if (ModelState.IsValid)
                {
                    OrganizationRequest Request = new OrganizationRequest();
                    Request.Organization.Organization = OrgAdminInfoModel.OrgName;
                    Request.Organization.IsEnabled    = OrgAdminInfoModel.IsOrgEnabled;
                    UserDTO AdminInfo = new UserDTO();

                    AdminInfo.FirstName           = OrgAdminInfoModel.AdminFirstName;
                    AdminInfo.LastName            = OrgAdminInfoModel.AdminLastName;
                    AdminInfo.EmailAddress        = OrgAdminInfoModel.AdminEmail;
                    AdminInfo.Role                = 2;
                    AdminInfo.PhoneNumber         = "123456789";
                    AdminInfo.UGuid               = Guid.NewGuid();
                    Request.OrganizationAdminInfo = AdminInfo;

                    Request.UserRole = UserHighestRole;
                    Request.UserId   = UserId;
                    Request.Action   = "Insert";
                    try
                    {
                        OrganizationResponse     Result        = _isurveyFacade.SetOrganization(Request);
                        OrgListModel             OrgListModel  = new OrgListModel();
                        OrganizationResponse     Organizations = _isurveyFacade.GetUserOrganizations(Request);
                        List <OrganizationModel> Model         = Mapper.ToOrganizationModelList(Organizations.OrganizationList);
                        OrgListModel.OrganizationList = Model;

                        if (Result.Message.ToUpper() != "EXISTS")
                        {
                            OrgListModel.Message = "Organization " + OrgAdminInfoModel.OrgName + " has been created.";
                        }
                        else
                        {
                            // OrgListModel.Message = "The organization name provided already exists.";
                            OrgAdminInfoModel OrgInfo = new OrgAdminInfoModel();
                            //Request.Organization.OrganizationKey = GetOrgKey(url); ;

                            //Organizations = _isurveyFacade.GetOrganizationInfo(Request);
                            OrgInfo            = Mapper.ToOrgAdminInfoModel(Organizations);
                            OrgInfo.IsEditMode = false;
                            ModelState.AddModelError("OrgName", "The organization name provided already exists.");
                            return(View("OrgInfo", OrgInfo));
                        }
                        return(View("OrgList", OrgListModel));
                    }
                    catch (Exception ex)
                    {
                        return(View(OrgAdminInfoModel));
                    }
                }
                else
                {
                    return(View(OrgAdminInfoModel));
                }
            }
        }
        public ActionResult OrgInfo(OrgAdminInfoModel orgAdminInfoModel)
        {
            int    userId          = GetIntSessionValue(UserSession.Key.UserId);
            int    userHighestRole = GetIntSessionValue(UserSession.Key.UserHighestRole);
            string url             = "";

            if (this.Request.UrlReferrer == null)
            {
                url = this.Request.Url.ToString();
            }
            else
            {
                url = this.Request.UrlReferrer.ToString();
            }
            //Edit Organization
            if (orgAdminInfoModel.IsEditMode)
            {
                ModelState.Remove("AdminFirstName");
                ModelState.Remove("AdminLastName");
                ModelState.Remove("ConfirmAdminEmail");
                ModelState.Remove("AdminEmail");

                OrganizationRequest request = new OrganizationRequest();

                UserDTO adminInfo = new UserDTO();

                adminInfo.FirstName           = "";
                adminInfo.LastName            = "";
                adminInfo.EmailAddress        = "";
                adminInfo.Role                = 0;
                adminInfo.PhoneNumber         = "";
                request.OrganizationAdminInfo = adminInfo;

                request.Organization.Organization       = orgAdminInfoModel.OrgName;
                request.Organization.IsEnabled          = orgAdminInfoModel.IsOrgEnabled;
                request.Organization.IsHostOrganization = orgAdminInfoModel.IsHostOrganization;

                request.Organization.OrganizationKey = GetOrgKey(url);
                request.UserId   = userId;
                request.UserRole = userHighestRole;
                request.Action   = RequestAction.Update;
                try
                {
                    OrganizationResponse     result        = _securityFacade.SetOrganization(request);
                    OrganizationResponse     organizations = _securityFacade.GetUserOrganizations(request);
                    List <OrganizationModel> model         = organizations.OrganizationList.ToOrganizationModelList();
                    OrgListModel             orgListModel  = new OrgListModel();
                    orgListModel.OrganizationList = model;
                    orgListModel.Message          = "Organization " + orgAdminInfoModel.OrgName + " has been updated.";
                    if (result.Message.ToUpper() != "EXISTS" && result.Message.ToUpper() != "ERROR")
                    {
                        orgListModel.Message = "Organization " + orgAdminInfoModel.OrgName + " has been updated.";
                        return(View(ViewActions.OrgList, orgListModel));
                    }
                    else if (result.Message.ToUpper() == "ERROR")
                    {
                        OrgAdminInfoModel orgInfo = new OrgAdminInfoModel();
                        request.Organization.OrganizationKey = GetOrgKey(url);;

                        organizations      = _securityFacade.GetOrganizationInfo(request);
                        orgInfo            = organizations.ToOrgAdminInfoModel();
                        orgInfo.IsEditMode = true;
                        ModelState.AddModelError("IsOrgEnabled", "Organization for the super admin cannot be deactivated.");
                        return(View(ViewActions.OrgInfo, orgInfo));
                    }
                    else
                    {
                        OrgAdminInfoModel orgInfo = new OrgAdminInfoModel();
                        request.Organization.OrganizationKey = GetOrgKey(url);;

                        organizations      = _securityFacade.GetOrganizationInfo(request);
                        orgInfo            = organizations.ToOrgAdminInfoModel();
                        orgInfo.IsEditMode = true;
                        ModelState.AddModelError("OrgName", "The organization name provided already exists.");
                        return(View(ViewActions.OrgInfo, orgInfo));
                    }
                }
                catch (Exception ex)
                {
                    return(View(orgAdminInfoModel));
                }
            }
            else
            {
                // Add new Organization

                if (ModelState.IsValid)
                {
                    OrganizationRequest request = new OrganizationRequest();
                    request.Organization.Organization       = orgAdminInfoModel.OrgName;
                    request.Organization.IsEnabled          = orgAdminInfoModel.IsOrgEnabled;
                    request.Organization.IsHostOrganization = orgAdminInfoModel.IsHostOrganization;
                    UserDTO adminInfo = new UserDTO();

                    adminInfo.FirstName           = orgAdminInfoModel.AdminFirstName;
                    adminInfo.LastName            = orgAdminInfoModel.AdminLastName;
                    adminInfo.EmailAddress        = orgAdminInfoModel.AdminEmail;
                    adminInfo.Role                = Roles.Administrator;
                    adminInfo.PhoneNumber         = "123456789";
                    adminInfo.UGuid               = Guid.NewGuid();
                    request.OrganizationAdminInfo = adminInfo;

                    request.UserRole = userHighestRole;
                    request.UserId   = userId;
                    request.Action   = RequestAction.Insert;
                    try
                    {
                        OrganizationResponse     result        = _securityFacade.SetOrganization(request);
                        OrgListModel             orgListModel  = new OrgListModel();
                        OrganizationResponse     organizations = _securityFacade.GetUserOrganizations(request);
                        List <OrganizationModel> model         = organizations.OrganizationList.ToOrganizationModelList();
                        orgListModel.OrganizationList = model;

                        if (result.Message.ToUpper() != "EXISTS")
                        {
                            orgListModel.Message = "Organization " + orgAdminInfoModel.OrgName + " has been created.";
                        }
                        else
                        {
                            // OrgListModel.Message = "The organization name provided already exists.";
                            OrgAdminInfoModel orgInfo = new OrgAdminInfoModel();
                            //Request.Organization.OrganizationKey = GetOrgKey(url); ;

                            //Organizations = _isurveyFacade.GetOrganizationInfo(Request);
                            orgInfo            = organizations.ToOrgAdminInfoModel();
                            orgInfo.IsEditMode = false;
                            ModelState.AddModelError("OrgName", "The organization name provided already exists.");
                            return(View(ViewActions.OrgInfo, orgInfo));
                        }
                        return(View(ViewActions.OrgList, orgListModel));
                    }
                    catch (Exception ex)
                    {
                        return(View(orgAdminInfoModel));
                    }
                }
                else
                {
                    return(View(orgAdminInfoModel));
                }
            }
        }