[AuthorizeUser(Enums.ApplicationActivity.BoostBestInClassNumberEdit)] // Added by Sohel Pathan on 19/06/2014 for PL ticket #537 to implement user permission Logic public ActionResult BestInClass() { // Added by Sohel Pathan on 19/06/2014 for PL ticket #537 to implement user permission Logic ViewBag.IsBoostBestInClassNumberEditAuthorized = AuthorizeUserAttribute.IsAuthorized(Enums.ApplicationActivity.BoostBestInClassNumberEdit); ViewBag.IsBoostImprovementTacticCreateEditAuthorized = AuthorizeUserAttribute.IsAuthorized(Enums.ApplicationActivity.BoostImprovementTacticCreateEdit); List <BestInClassModel> listBestInClassModel = new List <BestInClassModel>(); //added by uday for ticket #501 deleted old code and added new parameters like stagetype_cr etc. try { #region "Enum Variables" string StageType_CR = Enums.StageType.CR.ToString(); string StageType_SV = Enums.StageType.SV.ToString(); string StageType_Size = Enums.StageType.Size.ToString(); string CW = Enums.Stage.CW.ToString(); #endregion var bicfilter = db.BestInClasses.Where(cls => cls.Stage.ClientId == Sessions.User.CID).OrderBy(cls => cls.StageId).ToList(); var stagefilter = GetStageListbyClientId(Sessions.User.ID); //// Add all BestInClassModel details to list except CW Stage Code. foreach (var item in stagefilter.Where(stage => stage.Level != null && stage.Code != CW).OrderBy(stage => stage.Level).ToList()) { BestInClassModel objBestInClassModel = new BestInClassModel(); objBestInClassModel.StageName = Common.GetReplacedString(item.ConversionTitle); objBestInClassModel.ConversionValue = bicfilter.Where(cls => cls.StageId == item.StageId && cls.StageType == StageType_CR).Select(cls => cls.Value).FirstOrDefault(); objBestInClassModel.VelocityValue = bicfilter.Where(cls => cls.StageId == item.StageId && cls.StageType == StageType_SV).Select(cls => cls.Value).FirstOrDefault(); objBestInClassModel.StageID_CR = item.StageId; objBestInClassModel.StageID_SV = item.StageId; objBestInClassModel.StageType = StageType_CR; listBestInClassModel.Add(objBestInClassModel); } //// Add Stage level null BestInClassModel details to list. List <Stage> lstStages = GetStageListbyClientId(Sessions.User.CID); foreach (var itemSize in lstStages.Where(stage => stage.Level == null)) { BestInClassModel objBestInClassModel = new BestInClassModel(); objBestInClassModel.StageID_Size = itemSize.StageId; objBestInClassModel.StageName = itemSize.Title; objBestInClassModel.StageType = StageType_Size; objBestInClassModel.ConversionValue = bicfilter.Where(cls => cls.StageId == itemSize.StageId && cls.StageType == StageType_Size).Select(cls => cls.Value).FirstOrDefault(); listBestInClassModel.Add(objBestInClassModel); } } catch (Exception e) { ErrorSignal.FromCurrentContext().Raise(e); } return(View(listBestInClassModel.AsEnumerable())); }
public void Best_In_Class() { var routes = new RouteCollection(); Console.WriteLine("To Return BestInClass View.\n"); MRPEntities db = new MRPEntities(); HttpContext.Current = DataHelper.SetUserAndPermission(); BoostController objBoostController = new BoostController(); objBoostController.ControllerContext = new ControllerContext(MockHelpers.FakeUrlHelper.FakeHttpContext(), new RouteData(), objBoostController); objBoostController.Url = MockHelpers.FakeUrlHelper.UrlHelper(); var result = objBoostController.BestInClass() as ViewResult; List <BestInClassModel> objModelList = (List <BestInClassModel>)result.Model; BestInClassModel objModel = objModelList.FirstOrDefault(); var serializedData = new RouteValueDictionary(objModel); var resultvalue = serializedData["StageName"]; Assert.IsNotNull(result.Model); Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name + "\n The Assert Value: result.Model " + result.Model); Assert.IsNotNull(resultvalue.ToString()); Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name + "\n The Assert Value: resultvalue " + resultvalue.ToString()); }
public void Save_BIC() { var routes = new RouteCollection(); Console.WriteLine("Action to Save BIC.\n"); MRPEntities db = new MRPEntities(); HttpContext.Current = DataHelper.SetUserAndPermission(); BoostController objBoostController = new BoostController(); objBoostController.ControllerContext = new ControllerContext(MockHelpers.FakeUrlHelper.FakeHttpContext(), new RouteData(), objBoostController); objBoostController.Url = MockHelpers.FakeUrlHelper.UrlHelper(); int ModelId = DataHelper.GetModelId(); Sessions.User.CID = DataHelper.GetClientId(0, ModelId); int StageId = DataHelper.GetStageId(Sessions.User.CID); var TaskData = DataHelper.GetStageData(StageId); List <BestInClassModel> objBestinClassModelList = new List <BestInClassModel>(); BestInClassModel objBestinClassModel = new BestInClassModel(); objBestinClassModel.StageID_CR = StageId; objBestinClassModel.StageID_SV = StageId; objBestinClassModel.StageID_Size = StageId; objBestinClassModel.StageName = "CR"; objBestinClassModel.StageType = Enums.StageType.CR.ToString(); objBestinClassModel.ConversionValue = 10.0; objBestinClassModel.VelocityValue = 10.0; objBestinClassModelList.Add(objBestinClassModel); if (objBestinClassModelList != null && objBestinClassModelList.Count > 0) { var result = objBoostController.SaveBIC(objBestinClassModelList) as JsonResult; Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name + "\n The Assert Value result.data: " + result.Data); Assert.IsNotNull(result.Data); } }