public void CostAnalyzer()
        {
            long customerId = 1;
            SystemSummaryViewModel systemSummaryViewModel = new SystemSummaryViewModel();
            mockedCustomerRepository.Setup(m => m.GetAll()).Returns(new List<customer>().AsQueryable());
            mockedCustRepository.Setup(m => m.GetWaterSourceIds(customerId)).Returns(new customer_water() { first_sourceID = 1, second_sourceID = 1 });
            mockedCustRepository.Setup(m => m.GetCustomerTrains(customerId)).Returns(new List<train>());
            mockedVesselRepository.Setup(m => m.GetAll()).Returns((new List<vessel>()).AsQueryable());

            var controller = new CostAnalyzerController(mockedCustomerRepository.Object, mockedCustRepository.Object, mockedVesselRepository.Object, mockedCostAnalyzerService.Object);
            controller.ControllerContext = new ControllerContext();
            var mockedHttpContext = new Mock<HttpContextBase>();
            var mockedSessionState = new HttpSessionMock();
            mockedHttpContext.SetupGet(ctx => ctx.Session).Returns(mockedSessionState);
            controller.ControllerContext.HttpContext = mockedHttpContext.Object;
            controller.ControllerContext.HttpContext.Session["CustomerId"] = customerId;
            controller.ControllerContext.HttpContext.Session["HasTrainDetails"] = "Verify";

            var returnObj = controller.CostAnalyzer();
            Assert.IsNotNull(returnObj);
            Assert.IsInstanceOfType(returnObj, typeof(ViewResult));
            var result = (ViewResult)returnObj;
            Assert.IsNotNull(result);
            mockedCustomerRepository.Verify(m => m.GetAll(), Times.Once());
            mockedCustRepository.Verify(m => m.GetWaterSourceIds(customerId), Times.Once());
            mockedCustRepository.Verify(m => m.GetCustomerTrains(customerId), Times.Once());
            mockedVesselRepository.Verify(m => m.GetAll(), Times.Once());
        }
        public ActionResult Index()
        {
            var system_overview_model         = new SystemSummaryViewModel();
            ScheduleDBManager scheduleManager = new ScheduleDBManager();

            var usertable    = new UserTable <AppMember>(Context);
            var num_patients = usertable.GetUserByRole("Patient").Count();


            system_overview_model.Due_Refills         = new RefillLinesViewModel();
            system_overview_model.Due_Refills.Refills = new List <RefillLineViewModel>();

            system_overview_model.Pending_Refills         = new RefillLinesViewModel();
            system_overview_model.Pending_Refills.Refills = new List <RefillLineViewModel>();

            var retrievedduerefills = scheduleManager.getDueRefillsInfo();

            foreach (var refill in retrievedduerefills)
            {
                var refillline = new RefillLineViewModel()
                {
                    PatientName  = toUpperCase(refill.PatientName.ToString()),
                    MedicineName = refill.MedicationName.ToString(),
                    pId          = refill.Patient_Id,
                    IsSelected   = true
                };
                system_overview_model.Due_Refills.Refills.Add(refillline);
            }

            system_overview_model.number_patients = num_patients;
            return(View(system_overview_model));
        }
示例#3
0
        /// <summary>
        /// Returns an object representing the system summary
        /// </summary>
        private async Task <SystemSummaryViewModel> GetSystemSummaryAsync()
        {
            SystemSummaryViewModel systemSummary = new SystemSummaryViewModel();
            var houseHelps = await GetHouseHelpsAsync();

            systemSummary.TotalAdmins     = (await GetAdminsAsync()).Count();
            systemSummary.TotalHouseHelps = houseHelps.Count();
            systemSummary.TotalUsers      = _userManager.Users.Count();

            systemSummary.TotalReachOutsSent = 0;
            foreach (var user in houseHelps)
            {
                systemSummary.TotalReachOutsSent += user.ReachOuts.Count();
            }

            return(systemSummary);
        }
 public void ComputeDataPoints()
 {
     double numWeeks = 5;
     double startingss = 100;
     double maxDegSss = 10;
     SystemSummaryViewModel systemSummaryViewModel = new SystemSummaryViewModel();
     IPredictiveModelService service = new PredictiveModelService(mockedRepositoryTrain.Object, mockedRepositoryWaterData.Object, mockedPredictiveModelRepository.Object, mockedVesselRepository.Object);
     var returnObj = service.ComputeDataPoints(numWeeks, startingss, maxDegSss);
     Assert.IsNotNull(returnObj);
 }
        /// <summary>
        /// CostAnalyzer
        /// </summary>        
        /// <returns></returns>
        public ActionResult CostAnalyzer()
        {
            long customerId = 0;
            if (this.Session["CustomerId"] != null)
            {
                customerId = Convert.ToInt64(this.Session["CustomerId"]);
            }
            customer CustDetails = new customer();
            SystemSummaryViewModel SSVMDetails = new SystemSummaryViewModel();
            customer_water CustWaterDetails = null;
            try
            {
                //If valid customer id does not exist in the session
                if (customerId != 0)
                {
                    var Customer = this.customerRepository.GetAll();
                    CustDetails = Customer.Where(x => x.customerID == customerId).FirstOrDefault();
                    SSVMDetails = new SystemSummaryViewModel();
                    SSVMDetails.CustomerDetails = CustDetails;
                    CustWaterDetails = this.modifiedCustRepository.GetWaterSourceIds(customerId);
                }

                if (CustWaterDetails != null)
                {
                    if (CustWaterDetails.first_sourceID != 0)
                    {
                        SSVMDetails.WaterSourceOne = this.modifiedCustRepository.GetWaterSourceDetails(CustWaterDetails.first_sourceID);//Get first watersource details
                        if (SSVMDetails.WaterSourceOne != null)
                        {
                            SSVMDetails.WaterSourceOne.full_site_name = SSVMDetails.WaterSourceOne.full_site_name.Replace("@", string.Empty);//Remove @ symbol from the watersource name
                        }
                    }
                    else
                    {
                        SSVMDetails.WaterSourceOne = null;
                    }
                    if (CustWaterDetails.second_sourceID != 0)
                    {
                        SSVMDetails.WaterSourceTwo = this.modifiedCustRepository.GetWaterSourceDetails(CustWaterDetails.second_sourceID);//Get second watersource details
                        if (SSVMDetails.WaterSourceTwo != null)
                        {
                            SSVMDetails.WaterSourceTwo.full_site_name = SSVMDetails.WaterSourceTwo.full_site_name.Replace("@ ", string.Empty);//Remove @ symbol from the watersource name
                        }
                    }
                    else
                    {
                        SSVMDetails.WaterSourceTwo = null;
                    }
                    SSVMDetails.Trains = this.modifiedCustRepository.GetCustomerTrains(customerId);//Get list of cutomer train details
                }
                else
                {
                    this.Session["IsNewCustomer"] = "True";
                    this.Session["HasTrainDetails"] = "Check";
                }
                SSVMDetails.CustomerType = Convert.ToString(this.Session["IsNewCustomer"]);
                SSVMDetails.HasTrainDetails = Convert.ToString(this.Session["HasTrainDetails"]);
                if (Convert.ToString(this.Session["HasTrainDetails"]) == "Verify")
                {
                    var count = (this.vesselRepository.GetAll().Where(p => p.vessel_customerID == (customerId).ToString())).Count();
                    if (count != 0)
                    {
                        SSVMDetails.HasTrainDetails = "Yes";
                    }
                    else
                    {
                        SSVMDetails.HasTrainDetails = "No";
                    }
                }
            }
            catch
            {
                throw;
            }
            return this.View(SSVMDetails);
        }
 /// <summary>
 /// Predictive System Performance view
 /// </summary>
 /// <param name="id">customer identifier</param>
 /// <returns>Returns the Predictive System Performance view</returns>
 public ActionResult PredictiveSystemPerformance()
 {
     long customerId = 0;
     if (this.Session["CustomerId"] != null)
     {
         customerId = Convert.ToInt64(this.Session["CustomerId"]);
     }
     customer customerDetails = new customer();
     SystemSummaryViewModel ssvmDetails = new SystemSummaryViewModel();
     customer_water custWaterDetails = null;
     try
     {
         if (customerId != 0)
         {
             var Customer = this.customerRepository.GetAll();
             customerDetails = Customer.Where(x => x.customerID == customerId).FirstOrDefault();
             ssvmDetails = new SystemSummaryViewModel();
             ssvmDetails.CustomerDetails = customerDetails;
             custWaterDetails = this.modifiedCustomerRepository.GetWaterSourceIds(customerId);
         }
         if (custWaterDetails != null)
         {
             if (custWaterDetails.first_sourceID != 0)
             {
                 ssvmDetails.WaterSourceOne = this.modifiedCustomerRepository.GetWaterSourceDetails(custWaterDetails.first_sourceID);//Get first watersource details
                 if (ssvmDetails.WaterSourceOne != null)
                 {
                     ssvmDetails.WaterSourceOne.full_site_name = ssvmDetails.WaterSourceOne.full_site_name.Replace("@", string.Empty);//Remove @ symbol from the watersource name
                 }
             }
             else
             {
                 ssvmDetails.WaterSourceOne = null;
             }
             if (custWaterDetails.second_sourceID != 0)
             {
                 ssvmDetails.WaterSourceTwo = this.modifiedCustomerRepository.GetWaterSourceDetails(custWaterDetails.second_sourceID);//Get second watersource details
                 if (ssvmDetails.WaterSourceTwo != null)
                 {
                     ssvmDetails.WaterSourceTwo.full_site_name = ssvmDetails.WaterSourceTwo.full_site_name.Replace("@ ", string.Empty);//Remove @ symbol from the watersource name
                 }
             }
             else
             {
                 ssvmDetails.WaterSourceTwo = null;
             }
             ssvmDetails.Trains = this.modifiedCustomerRepository.GetCustomerTrains(customerId);//Get list of cutomer train details
         }
         else
         {
             this.Session["IsNewCustomer"] = "True";
             this.Session["HasTrainDetails"] = "Check";
         }
         ssvmDetails.CustomerType = Convert.ToString(this.Session["IsNewCustomer"]);
         ssvmDetails.HasTrainDetails = Convert.ToString(this.Session["HasTrainDetails"]);
         if (Convert.ToString(this.Session["HasTrainDetails"]) == "Verify")
         {
             var count = this.vesselRepository.GetAll().Where(p => p.vessel_customerID == (customerId).ToString()).Count();
             if (count != 0)
             {
                 ssvmDetails.HasTrainDetails = "Yes";
             }
             else
             {
                 ssvmDetails.HasTrainDetails = "No";
             }
         }
         WaterStatisticsViewModel objWaterStatisticsViewModel = new WaterStatisticsViewModel();
         objWaterStatisticsViewModel = this.modifiedPredictiveRepository.GetWaterStatistics(customerId);
         ssvmDetails.waterStatisticsViewModeldetails = objWaterStatisticsViewModel;
     }
     catch (Exception)
     {
         throw;
     }
     return this.View(ssvmDetails);
 }
        public ActionResult WaterConductivity()
        {
            long customerId = 0;
            if (this.Session["CustomerId"] != null)
            {
                customerId = Convert.ToInt64(this.Session["CustomerId"]);
            }
            customer CustDetails = new customer();
            SystemSummaryViewModel SSVMDetails = new SystemSummaryViewModel();
            customer_water CustWaterDetails = null;
            try
            {
                //If valid customer id does not exist in the session
                if (customerId != 0)
                {
                    var Customer = this.customerRepository.GetAll();
                    CustDetails = Customer.Where(x => x.customerID == customerId).FirstOrDefault();
                    SSVMDetails = new SystemSummaryViewModel();
                    SSVMDetails.CustomerDetails = CustDetails;
                    CustWaterDetails = this.modifiedCustRepository.GetWaterSourceIds(customerId);
                }

                if (CustWaterDetails != null)
                {
                    if (CustWaterDetails.first_sourceID != 0)
                    {
                        SSVMDetails.WaterSourceOne = this.modifiedCustRepository.GetWaterSourceDetails(CustWaterDetails.first_sourceID);//Get first watersource details
                        if (SSVMDetails.WaterSourceOne != null)
                        {
                            SSVMDetails.WaterSourceOne.full_site_name = SSVMDetails.WaterSourceOne.full_site_name.Replace("@", string.Empty);//Remove @ symbol from the watersource name
                            SSVMDetails.Source1Statistics = this.conductivityService.CalculateStatistics(CustWaterDetails.first_sourceID);
                        }
                    }
                    else
                    {
                        SSVMDetails.WaterSourceOne = null;
                    }
                    if (CustWaterDetails.second_sourceID != 0)
                    {
                        SSVMDetails.WaterSourceTwo = this.modifiedCustRepository.GetWaterSourceDetails(CustWaterDetails.second_sourceID);//Get second watersource details
                        if (SSVMDetails.WaterSourceTwo != null)
                        {
                            SSVMDetails.WaterSourceTwo.full_site_name = SSVMDetails.WaterSourceTwo.full_site_name.Replace("@ ", string.Empty);//Remove @ symbol from the watersource name
                            SSVMDetails.Source2Statistics = this.conductivityService.CalculateStatistics(CustWaterDetails.second_sourceID);
                        }
                    }
                    else
                    {
                        SSVMDetails.WaterSourceTwo = null;
                    }
                    SSVMDetails.Trains = this.modifiedCustRepository.GetCustomerTrains(customerId);//Get list of cutomer train details
                }
                else
                {
                    this.Session["IsNewCustomer"] = "True";
                    this.Session["HasTrainDetails"] = "Check";
                }

            }
            catch
            {
                throw;
            }
            return this.View(SSVMDetails);
        }