Пример #1
0
        public void ResetPassword_Post()
        {
            var routes = new RouteCollection();

            Console.WriteLine("To Reset Password Post.\n");
            MRPEntities db = new MRPEntities();

            HttpContext.Current = DataHelper.SetUserAndPermission();
            BDSService.BDSServiceClient objBDSServiceClient = new BDSService.BDSServiceClient();
            LoginController             objLoginController  = new LoginController();

            objLoginController.ControllerContext = new ControllerContext(MockHelpers.FakeUrlHelper.FakeHttpContext(), new RouteData(), objLoginController);
            objLoginController.Url = MockHelpers.FakeUrlHelper.UrlHelper();
            int PlanId = DataHelper.GetPlanId();

            Sessions.User.CID = DataHelper.GetClientId(PlanId);
            Sessions.User.ID  = DataHelper.GetUserId(PlanId);
            ResetPasswordModel form = new ResetPasswordModel();

            form.UserId             = Sessions.User.ID;
            form.NewPassword        = Convert.ToString(ConfigurationManager.AppSettings["Password"]);
            form.ConfirmNewPassword = Convert.ToString(ConfigurationManager.AppSettings["Password"]);
            var result         = objLoginController.ResetPassword(form) as ViewResult;
            var serializedData = new RouteValueDictionary(result.Model);
            var resultvalue    = serializedData["UserId"];

            Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name + "  : Pass \n The Assert Value:  " + resultvalue.ToString());
            Assert.AreEqual(Sessions.User.ID.ToString(), resultvalue.ToString());
        }
Пример #2
0
        public void Assign_User()
        {
            var routes = new RouteCollection();

            Console.WriteLine("Assign Other Application User.\n");
            MRPEntities db = new MRPEntities();

            HttpContext.Current = DataHelper.SetUserAndPermission();
            UserController objUserController = new UserController();

            objUserController.ControllerContext = new ControllerContext(MockHelpers.FakeUrlHelper.FakeHttpContext(), new RouteData(), objUserController);
            objUserController.Url = MockHelpers.FakeUrlHelper.UrlHelper();

            int PlanId = DataHelper.GetPlanId();

            Sessions.User.CID = DataHelper.GetClientId(PlanId);
            Sessions.PlanId   = PlanId;
            Sessions.User.ID  = DataHelper.GetUserId(PlanId);
            BDSService.BDSServiceClient objBDSServiceClient = new BDSService.BDSServiceClient();
            var objUser = objBDSServiceClient.GetTeamMemberDetailsEx(Sessions.User.ID, Sessions.ApplicationId);

            if (objUser != null)
            {
                int    userId = objUser.ID;
                string RoleId = objUser.RoleId.ToString();
                var    result = objUserController.AssignUser(userId, RoleId) as JsonResult;
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name + "\n The Assert Value result:  " + result.Data);
                Assert.IsNotNull(result.Data);
            }
        }
Пример #3
0
        public void Email_Exist_with_Old_EmailId()
        {
            var routes = new RouteCollection();

            Console.WriteLine("To Check Email Exist or Not with existing emailId.\n");
            MRPEntities db = new MRPEntities();

            HttpContext.Current = DataHelper.SetUserAndPermission();
            UserController objUserController = new UserController();

            objUserController.ControllerContext = new ControllerContext(MockHelpers.FakeUrlHelper.FakeHttpContext(), new RouteData(), objUserController);
            objUserController.Url = MockHelpers.FakeUrlHelper.UrlHelper();

            int PlanId = DataHelper.GetPlanId();

            Sessions.User.CID = DataHelper.GetClientId(PlanId);
            Sessions.PlanId   = PlanId;
            Sessions.User.ID  = DataHelper.GetUserId(PlanId);
            BDSService.BDSServiceClient objBDSServiceClient = new BDSService.BDSServiceClient();
            var objUser = objBDSServiceClient.GetTeamMemberDetailsEx(Sessions.User.ID, Sessions.ApplicationId);

            if (objUser != null)
            {
                string Email  = objUser.Email;
                var    result = objUserController.IsEmailExist(Email) as JsonResult;
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name + "\n The Assert Value result:  " + result.Data);
                Assert.IsNotNull(result.Data);
            }
        }
Пример #4
0
        public void MaintenanceSite()
        {
            var routes = new RouteCollection();

            Console.WriteLine("returnt Site maintainance.\n");
            MRPEntities db = new MRPEntities();

            HttpContext.Current = DataHelper.SetUserAndPermission();
            BDSService.BDSServiceClient objBDSServiceClient = new BDSService.BDSServiceClient();
            LoginController             objLoginController  = new LoginController();

            objLoginController.ControllerContext = new ControllerContext(MockHelpers.FakeUrlHelper.FakeHttpContext(), new RouteData(), objLoginController);
            objLoginController.Url = MockHelpers.FakeUrlHelper.UrlHelper();
            var result = objLoginController.MaintenanceSite() as ViewResult;

            Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name + "  : Pass \n The Assert Value ViewName:  " + result.ViewName);
            Assert.IsNotNull(result.ViewName);
        }
Пример #5
0
        public void CheckCurrentPassword()
        {
            var routes = new RouteCollection();

            Console.WriteLine("Check Current Password.\n");
            MRPEntities db = new MRPEntities();

            HttpContext.Current = DataHelper.SetUserAndPermission();
            BDSService.BDSServiceClient objBDSServiceClient = new BDSService.BDSServiceClient();
            LoginController             objLoginController  = new LoginController();

            objLoginController.ControllerContext = new ControllerContext(MockHelpers.FakeUrlHelper.FakeHttpContext(), new RouteData(), objLoginController);
            objLoginController.Url = MockHelpers.FakeUrlHelper.UrlHelper();
            int PlanId = DataHelper.GetPlanId();

            Sessions.User.CID = DataHelper.GetClientId(PlanId);
            Sessions.User.ID  = DataHelper.GetUserId(PlanId);
            string currentPassword = Convert.ToString(ConfigurationManager.AppSettings["Password"]);
            var    result          = objLoginController.CheckCurrentPassword(currentPassword, Sessions.User.ID) as JsonResult;

            Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name + "  : Pass \n The Assert Value result.Data:  " + result.Data);
            Assert.IsNotNull(result.Data);
        }
Пример #6
0
        public void ResetPassword_View()
        {
            var routes = new RouteCollection();

            Console.WriteLine("To Reset Password View.\n");
            MRPEntities db = new MRPEntities();

            HttpContext.Current = DataHelper.SetUserAndPermission();
            BDSService.BDSServiceClient objBDSServiceClient = new BDSService.BDSServiceClient();
            LoginController             objLoginController  = new LoginController();

            objLoginController.ControllerContext = new ControllerContext(MockHelpers.FakeUrlHelper.FakeHttpContext(), new RouteData(), objLoginController);
            objLoginController.Url = MockHelpers.FakeUrlHelper.UrlHelper();
            int PlanId = DataHelper.GetPlanId();

            Sessions.User.CID = DataHelper.GetClientId(PlanId);
            Sessions.User.ID  = DataHelper.GetUserId(PlanId);
            var lstUser = objBDSServiceClient.GetTeamMemberListEx(Sessions.User.CID, Sessions.ApplicationId, Sessions.User.ID, true);

            if (lstUser != null && lstUser.Count > 0)
            {
                string Email   = lstUser.FirstOrDefault().Email;
                var    objUser = objBDSServiceClient.GetUserDetails(Email);
                BDSService.PasswordResetRequest objPasswordResetRequest = new BDSService.PasswordResetRequest();
                objPasswordResetRequest.PasswordResetRequestId = Guid.NewGuid();
                objPasswordResetRequest.UserId       = objUser.UserId;
                objPasswordResetRequest.AttemptCount = 0;
                objPasswordResetRequest.CreatedDate  = DateTime.Now;
                string PasswordResetRequestId = objBDSServiceClient.CreatePasswordResetRequest(objPasswordResetRequest);
                var    result         = objLoginController.ResetPassword(PasswordResetRequestId, false) as ViewResult;
                var    serializedData = new RouteValueDictionary(result.Model);
                var    resultvalue    = serializedData["UserId"];
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name + "  : Pass \n The Assert Value resultvalue:  " + resultvalue.ToString());
                Assert.AreEqual(objUser.ID.ToString(), resultvalue.ToString());
            }
        }
Пример #7
0
        /// <summary>
        /// Add By Nishant Sheth
        /// #2496 : Set the cache of currency exchange rate for users's preferd currency
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="userId"></param>
        public void SetUserCurrencyCache(int clientId, int userId)
        {
            try
            {
                BDSService.BDSServiceClient objBDSServiceClient = new BDSService.BDSServiceClient();
                BDSService.Currency         objUserCurrency     = new BDSService.Currency();

                DateTime now = DateTime.Now;
                DateTime CurrentMonthStartDate = GetFirstDayOfMonth(now.Month, now.Year);
                DateTime CurrentMonthEndDate   = GetLastDayOfMonth(now.Month, now.Year);

                objUserCurrency = objBDSServiceClient.GetCurrencyExchangeRateEx(clientId, userId); // Call the BDS Sevice for get exchange rate

                if (objUserCurrency.UserCurrency != null)
                {
                    var Currency = objUserCurrency.UserCurrency;
                    // Get Planning Exchange rate // With Current Start Date and end date
                    RevenuePlanner.Models.CurrencyModel.PlanCurrency UserPlanCurrency = Currency.CurrencyExchangeRate
                                                                                        .Where(curr => curr.CurrencyCode == Currency.UserPreferredCurrencyCode &&
                                                                                               curr.Component == Enums.CurrencyComponent.Plan.ToString().ToLower() &&
                                                                                               (curr.StartDate >= CurrentMonthStartDate && curr.EndDate <= CurrentMonthEndDate))
                                                                                        .Select(curr =>
                                                                                                new RevenuePlanner.Models.CurrencyModel.PlanCurrency
                    {
                        CurrencyCode   = curr.CurrencyCode,
                        CurrencySymbol = curr.CurrencySymbol,
                        ExchangeRate   = curr.ExchangeRate
                    }).FirstOrDefault();

                    if (UserPlanCurrency != null)
                    {
                        objCache.AddCache(Convert.ToString(Enums.CacheObject.UserPlanCurrency), UserPlanCurrency);
                        Sessions.PlanExchangeRate = UserPlanCurrency.ExchangeRate;
                    }
                    else
                    {
                        Sessions.PlanExchangeRate = 1;
                    }

                    // Get Reporting Exchange rate
                    List <RevenuePlanner.Models.CurrencyModel.ClientCurrency> UserReportCurrency = Currency.CurrencyExchangeRate
                                                                                                   .Where(curr => curr.CurrencyCode == Currency.UserPreferredCurrencyCode &&
                                                                                                          curr.Component == Enums.CurrencyComponent.Report.ToString().ToLower())
                                                                                                   .Select(curr =>
                                                                                                           new RevenuePlanner.Models.CurrencyModel.ClientCurrency
                    {
                        ClientId       = curr.CID,
                        Component      = curr.Component,
                        CurrencyCode   = curr.CurrencyCode,
                        CurrencySymbol = curr.CurrencySymbol,
                        EndDate        = curr.EndDate,
                        ExchangeRate   = curr.ExchangeRate,
                        StartDate      = curr.StartDate
                    }).ToList();

                    if (UserReportCurrency != null)
                    {
                        objCache.AddCache(Enums.CacheObject.ListUserReportCurrency.ToString(), UserReportCurrency);
                    }
                    Sessions.PlanCurrencySymbol = Currency.UserPreferredCurrencySymbol;
                }
                else
                {
                    Sessions.PlanExchangeRate   = 1;
                    Sessions.PlanCurrencySymbol = Convert.ToString(Enums.CurrencySymbolsValues[Enums.CurrencySymbols.USD.ToString()]);
                }
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }
Пример #8
0
        //Added by komal rawal on 16-08-2016 regarding #2484 save notifications
        public int SaveLogNoticationdata(string action, string actionSuffix, int?componentId, string componentTitle, string description, int?objectid, int?parentObjectId, string TableName, int ClientId, int User, string UserName, int EntityOwnerID, string ReportRecipientUserIds)
        {
            int returnvalue = 0;

            List <int> lst_RecipientId = new List <int>();

            if (description == Convert.ToString(Enums.ChangeLog_ComponentType.tactic).ToLower() && componentId != null)
            {
                if (action == Convert.ToString(Enums.ChangeLog_Actions.submitted))
                {
                    BDSService.BDSServiceClient objBDSUserRepository = new BDSService.BDSServiceClient();
                    var lstUserHierarchy = objBDSUserRepository.GetUserHierarchyEx(Sessions.User.CID, Sessions.ApplicationId);
                    var objOwnerUser     = lstUserHierarchy.FirstOrDefault(u => u.UID == EntityOwnerID);
                    lst_RecipientId.Add(objOwnerUser.MID);
                    lst_RecipientId.Add(EntityOwnerID);
                }
                else
                {
                    lst_RecipientId = Common.GetCollaboratorForTactic(Convert.ToInt32(componentId));
                }
            }
            else if (description == Convert.ToString(Enums.ChangeLog_ComponentType.program).ToLower() && componentId != null)
            {
                lst_RecipientId = Common.GetCollaboratorForProgram(Convert.ToInt32(componentId));
            }
            else if (description == Convert.ToString(Enums.ChangeLog_ComponentType.campaign).ToLower() && componentId != null)
            {
                lst_RecipientId = Common.GetCollaboratorForCampaign(Convert.ToInt32(componentId));
            }
            else if ((description == Convert.ToString(Enums.ChangeLog_ComponentType.plan).ToLower() || description == Convert.ToString(Enums.PlanEntityValues[Enums.PlanEntity.LineItem.ToString()]).ToLower()) && componentId != null && EntityOwnerID != 0)
            {
                lst_RecipientId.Add(EntityOwnerID);
            }

            string RecipientIds = null;

            if (lst_RecipientId.Count > 0)
            {
                RecipientIds = String.Join(",", lst_RecipientId);
            }
            else if (TableName == Convert.ToString(Enums.ChangeLog_TableName.Report) && action == Convert.ToString(Enums.ChangeLog_Actions.shared))
            {
                RecipientIds = ReportRecipientUserIds;
            }
            Connection = Conn_Open();
            using (command = new SqlCommand("SaveLogNoticationdata", Connection))
            {
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@action", action);
                command.Parameters.AddWithValue("@actionSuffix", actionSuffix);
                command.Parameters.AddWithValue("@componentId", componentId);
                command.Parameters.AddWithValue("@componentTitle", componentTitle);
                command.Parameters.AddWithValue("@description", description);
                command.Parameters.AddWithValue("@objectId", objectid);
                command.Parameters.AddWithValue("@parentObjectId", parentObjectId);
                command.Parameters.AddWithValue("@TableName", TableName);
                command.Parameters.AddWithValue("@Userid", User);
                command.Parameters.AddWithValue("@ClientId", ClientId);
                command.Parameters.AddWithValue("@UserName", UserName);
                command.Parameters.AddWithValue("@RecipientIDs", RecipientIds);
                command.Parameters.AddWithValue("@EntityOwnerID", EntityOwnerID);
                string returnvalue1 = command.ExecuteScalar().ToString();
                //  adp.Fill(dataset);
                returnvalue = Convert.ToInt32(returnvalue1);
                Conn_Close();
            }
            return(returnvalue);
        }