示例#1
0
        public IActionResult requestAdhocRefill([FromBody] RefillOrderLine order)
        {
            RefillDetails detail = ls.Where(x => x.Member_ID == order.Member_ID).FirstOrDefault();

            //string data = JsonConvert.SerializeObject(order);
            //int x = obj.Drug_ID;
            Uri        baseAddress = new Uri("https://localhost:44372/api/Drugs/" + detail.DrugID);
            HttpClient client      = new HttpClient();

            client.BaseAddress = baseAddress;

            HttpResponseMessage response = client.GetAsync(client.BaseAddress).Result;

            if (response.IsSuccessStatusCode)
            {
                string data = response.Content.ReadAsStringAsync().Result;
                Drug   s    = JsonConvert.DeserializeObject <Drug>(data);
                if (s.drugLocation.Location == order.Location)
                {
                    return(Ok(detail));
                }
                return(Ok("Unavailable"));
            }

            return(BadRequest());
        }
示例#2
0
        public IActionResult requestAdhocRefill([FromBody] RefillOrderLine order)
        {
            _log4net.Info(" Http POST request for Adhoc Refill Status");

            string Token = HttpContext.Request.Headers["Authorization"].Single().Split(" ")[1];

            RefillRepository fill    = new RefillRepository();
            RefillDetails    details = new RefillDetails();

            details = fill.requestAdhocRefill(order, Token);
            if (details == null)
            {
                return(BadRequest());
            }
            return(Ok(details));
        }
 public void RefillById_InValid_RefillDetails()
 {
     try
     {
         RefillDetails            obj  = new RefillDetails();
         Mock <IRefillRepository> mock = new Mock <IRefillRepository>();
         mock.Setup(p => p.viewRefillStatus(10)).Returns(null);
         RefillController r = new RefillController(mock.Object);
         var data           = r.RefillStatus(10) as OkObjectResult;
         Assert.AreEqual(200, data.StatusCode);
     }
     catch (Exception e)
     {
         Assert.AreEqual("Object reference not set to an instance of an object.", e.Message);
     }
 }
示例#4
0
        /// <summary>
        /// This method calculates the next refill date
        /// </summary>
        /// <param name="subscription_id"></param>
        /// <param name="freq"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public dynamic Calculation_Dues(int subscription_id, string freq, DateTime date)
        {
            List <RefillDetails> Pending = new List <RefillDetails>();

            if (string.Equals(freq, "Weekly"))
            {
                int month    = date.Month;
                int nxtmonth = month + 1;

                while (month != nxtmonth)
                {
                    RefillDetails refill = new RefillDetails();
                    refill.Subscription_ID = subscription_id;

                    date = date.AddDays(7);
                    refill.RefillDate     = date;
                    refill.NextRefillDate = date.AddDays(7);
                    Pending.Add(refill);
                    month = date.Month;
                }
            }
            else

            {
                int year    = date.Year;
                int nxtyear = year + 1;

                while (year != nxtyear)
                {
                    RefillDetails refill = new RefillDetails();
                    refill.Subscription_ID = subscription_id;

                    date = date.AddMonths(1);
                    refill.RefillDate     = date;
                    refill.NextRefillDate = date.AddMonths(1);
                    Pending.Add(refill);
                    year = date.Year;
                }
            }
            return(Pending);
        }
示例#5
0
        public IEnumerable <RefillDetails> PendingRefill(int id, DateTime date, string freq)
        {
            List <RefillDetails> Pending = new List <RefillDetails>();

            if (freq == "Weekly")
            {
                int month    = date.Month;
                int nxtmonth = month + 1;

                while (month != nxtmonth)
                {
                    RefillDetails refill = new RefillDetails();
                    refill.Subscription_ID = id;

                    date = date.AddDays(7);
                    refill.RefillDate     = date;
                    refill.NextRefillDate = date.AddDays(7);
                    Pending.Add(refill);
                    month = date.Month;
                }
            }
            else

            {
                int year    = date.Year;
                int nxtyear = year + 1;

                while (year != nxtyear)
                {
                    RefillDetails refill = new RefillDetails();
                    refill.Subscription_ID = id;

                    date = date.AddMonths(1);
                    refill.RefillDate     = date;
                    refill.NextRefillDate = date.AddMonths(1);
                    Pending.Add(refill);
                    year = date.Year;
                }
            }
            return(Pending);
        }
示例#6
0
        public IActionResult requestAdhocRefill([FromBody] RefillOrderLine order)
        {
            if (HttpContext == null)
            {
                Token = "Token";
            }
            else
            {
                Token = HttpContext.Request.Headers["Authorization"].Single().Split(" ")[1];
            }
            _log4net.Info(" Http POST request for Adhoc Refill Status");

            RefillDetails details = new RefillDetails();

            details = _refill.requestAdhocRefill(order, Token);
            if (details == null)
            {
                return(null);
            }
            return(Ok(details));
        }
示例#7
0
        /// <summary>
        /// This method checks the adhoc refill details
        /// </summary>
        /// <param name="order"></param>
        /// <param name="Token"></param>
        /// <returns></returns>
        public virtual dynamic requestAdhocRefill(RefillOrderLine order, string Token)
        {
            RefillDetails detail      = ls.Where(x => x.Member_ID == order.Member_ID).FirstOrDefault();
            Uri           baseAddress = new Uri("http://52.154.215.101/api/Drugs/GetDrugDetails/" + detail.DrugID);
            HttpClient    client      = new HttpClient();

            client.BaseAddress = baseAddress;

            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token);
            HttpResponseMessage response = client.GetAsync(client.BaseAddress).Result;

            if (response.IsSuccessStatusCode)
            {
                string data = response.Content.ReadAsStringAsync().Result;
                Drug   s    = JsonConvert.DeserializeObject <Drug>(data);
                if (s.drugLocation.Location == order.Location)
                {
                    return(detail);
                }
                return("Unavailable");
            }
            return(null);
        }