Exemple #1
0
        public void MedicineStockInfoTest()
        {
            IEnumerable <MedicineStockDTO> answer = pro.GetMedicineStock();

            Assert.AreEqual(medicineStock, answer);
            Assert.Pass();
        }
Exemple #2
0
        public async Task <List <RepSchedule> > GetRepScheduleAsync(DateTime startDate)
        {
            try
            {
                if (_dates.Count > 0)
                {
                    _dates.Clear();
                }

                DateTime start    = startDate;
                DateTime end      = start.AddDays(6);
                int      workDays = 0;
                while (start != end)
                {
                    if (start.DayOfWeek != DayOfWeek.Sunday)
                    {
                        _dates.Add(start);
                        workDays++;
                    }
                    if (workDays == 5)
                    {
                        break;
                    }
                    start = start.AddDays(1);
                }
                _repNames = GetRepresentatives();
                _stock    = await _medicineStockProvider.GetMedicineStock();

                _docNames = GetDoctors();
                if (_repNames == null || !_repNames.Any <RepresentativeDetailsDTO>() || !_stock.Any <MedicineStock>() || _stock == null || !_docNames.Any <DoctorDTO>() || _docNames == null)
                {
                    _log.Error("Could not get RepName or Stock or DocName");
                    return(null);
                }
                for (var i = 0; i < _dates.Count; i++)
                {
                    var rep = new RepSchedule
                    {
                        RepName         = _repNames[(i % _repNames.Count)].RepresentativeName,
                        DoctorName      = _docNames[i].Name,
                        TreatingAilment = _docNames[i].TreatingAilment,
                        MeetingSlot     = "1pm-2pm",
                        DateOfMeeting   = _dates[i].ToShortDateString()
                    };
                    var meds = (from s in _stock where s.TargetAilment.Contains(_docNames[i].TreatingAilment) select s.Name).ToList();
                    rep.Medicine            = string.Join(",", meds);
                    rep.DoctorContactNumber = _docNames[i].ContactNumber;
                    _repSchedule.Add(rep);
                }
                _log.Info("returning schedule");
                return(_repSchedule);
            }
            catch (Exception e)
            {
                _log.Error("Error while scheduling - " + e.Message);
                throw;
            }
        }
Exemple #3
0
        public void MedicineStockInfoTest_FailCase_Service()
        {
            medicineStock = null;
            _pro.Setup(x => x.GetMedicineStock()).Returns(medicineStock);
            pro = _pro.Object;
            List <MedicineStock> result = (List <MedicineStock>)pro.GetMedicineStock();

            Assert.IsNull(result);
        }
Exemple #4
0
        public IActionResult Get()
        {
            try
            {
                var res = iMedicineStock.GetMedicineStock();

                if (res != null)
                {
                    return(Ok(res.ToList()));
                }

                return(Content("No such details found please try again."));
            }
            catch (Exception e)
            {
                return(Content("The following exception has occurred while retreving the stock." + e.Message + " Please try again"));
            }
        }
        public IActionResult Get()
        {
            try
            {
                var res = iMedicineStock.GetMedicineStock();

                if (res != null)
                {
                    _log.Info("Medicine Stock Retrived");
                    return(Ok(res.ToList()));
                }
                _log.Info("No details retrieved");
                return(Content("No such details found please try again."));
            }
            catch (Exception e)
            {
                _log.Error("Excpetion:" + e.Message + " has occurred while trying to retrieve stock info.");
                return(Content("The following exception has occurred while retreving the stock." + e.Message + " Please try again"));
            }
        }
Exemple #6
0
 public IActionResult Get()
 {
     try
     {
         var res = iMedicineStock.GetMedicineStock();
         BasicConfigurator.Configure();
         if (res != null)
         {
             log.Info("Medicine Stock Retrieved");
             return(Ok(res.ToList()));
         }
         log.Info("No details retrieved");
         return(NotFound("No such details found please try again."));
     }
     catch (Exception e)
     {
         log.Error("Exception:" + e.Message + " has occurred while trying to retrieve stock info.");
         return(StatusCode(500));
     }
 }