Пример #1
0
        public IActionResult SearchPurchaseOrderDetails(int pageNum, int pageSize, SearchOrderDetailsRequest searchRequest)
        {
            if (searchRequest.StartDate == null || searchRequest.EndDate == null)
            {
                return(BadRequest("Invalid arguments"));
            }
            IQueryable <PurchaseOrderDetail> searchResult;

            try
            {
                bool startDateParsed = DateParser.ParseDate(searchRequest.StartDate, out DateTime startDatePassed);
                bool endDateParsed   = DateParser.ParseDate(searchRequest.EndDate, out DateTime endDatePassed);
                searchResult = purchaseOrderDetailAppService.SearchPurchaseOrderDetails(
                    startDateParsed ? startDatePassed as DateTime? : null,
                    endDateParsed ? endDatePassed as DateTime? : null);
            }
            catch (Exception e)
            {
                // TODO: log exception stack trace
                return(BadRequest("Invalid arguments"));
            }

            var filteredResult = from order in searchResult
                                 group order by order.DueDate into d
                                 select new
            {
                Date      = d.Key,
                LineTotal = d.Sum(order => order.LineTotal),
                Quantity  = d.Sum(order => order.OrderQty),
                TotalSum  = d.Sum(order => order.LineTotal) + d.Sum(order => order.OrderQty)
            };

            filteredResult.OrderBy(m => m.Date).ToPagedList(pageNum, pageSize);
            return(Ok(filteredResult));
        }
Пример #2
0
        public void TestShouldIgnoreTimestamp()
        {
            //Calendar aDate = Calendar.getInstance();
            //aDate.setTime(new Date(84, OCTOBER, 20));
            DateTime aDate = DateTime.Parse("84-10-20");

            Assert.AreEqual(aDate, DateParser.ParseDate("1984/10/20 12:34:56"));
        }
Пример #3
0
        public void WillThrowArgumentException(string startDate, string endDate)
        {
            bool startDateParsed = DateParser.ParseDate(startDate, out DateTime startDatePassed);
            bool endDateParsed   = DateParser.ParseDate(endDate, out DateTime endDatePassed);

            Assert.Throws <ArgumentException>(() => purchaseOrderDetailService.SearchPurchaseOrderDetails(
                                                  startDateParsed ? startDatePassed as DateTime? : null,
                                                  endDateParsed ? endDatePassed as DateTime? : null));
        }
        public async Task HandleEvent(DeparturesPlannedArrivalDateUpdated depEvent)
        {
            var depList = await _departureRepository.FetchByIds(new[] { depEvent.DepartureId });

            var dep = depList.First();

            dep.ArrivalSchedule.PlannedTime.Date = DateParser.ParseDate(depEvent.Date);
            await _departureRepository.Update(dep);
        }
        public void WillNotFindProductByNameAndSellStartDate(string name, string sellStartDate, int expectedNumOfProductsFound)
        {
            bool dateParsed = DateParser.ParseDate(sellStartDate, out DateTime datePassed);
            IQueryable <Product> productsFound = productService.SearchProducts(
                name, dateParsed ? datePassed as DateTime? : null);

            Assert.NotNull(productsFound);
            Assert.Equal(expectedNumOfProductsFound, productsFound.Count());
        }
Пример #6
0
        public void WillNotFindOrderByStartDateAndEndDate(string startDate, string endDate, int expectedNumOfOrdersFound)
        {
            bool startDateParsed = DateParser.ParseDate(startDate, out DateTime startDatePassed);
            bool endDateParsed   = DateParser.ParseDate(endDate, out DateTime endDatePassed);
            IQueryable <PurchaseOrderDetail> ordersFound = purchaseOrderDetailService.SearchPurchaseOrderDetails(
                startDateParsed ? startDatePassed as DateTime? : null,
                endDateParsed ? endDatePassed as DateTime? : null);

            Assert.NotNull(ordersFound);
            Assert.Equal(expectedNumOfOrdersFound, ordersFound.Count());
        }
Пример #7
0
        public IActionResult SearchProducts(int pageNum, int pageSize, SearchProductsRequest searchRequest)
        {
            bool dateParsed = DateParser.ParseDate(searchRequest.SellStartDate, out DateTime datePassed);
            IQueryable <Product> searchResult = productAppService.SearchProducts(
                searchRequest.Name, dateParsed ? datePassed as DateTime? : null, searchRequest.DescriptionKeyWords);

            if (searchResult == null)
            {
                return(NotFound());
            }
            return(Ok(searchResult.OrderBy(m => m.SellStartDate).ToPagedList(pageNum, pageSize).Select(m => new { m.Name, m.SellStartDate })));
        }
Пример #8
0
 public void TestFailWhenLooksLikeDateButItIsnt()
 {
     try
     {
         DateParser.ParseDate("potato/cucumber/banana");
         Assert.Fail("Shouldn't parse this thing!");
     }
     catch (EvaluationException e)
     {
         Assert.AreEqual(ErrorEval.VALUE_INVALID, e.GetErrorEval());
     }
 }
Пример #9
0
 public void TestFailWhenIsInvalidDate()
 {
     try
     {
         DateParser.ParseDate("13/13/13");
         Assert.Fail("Shouldn't parse this thing!");
     }
     catch (EvaluationException e)
     {
         Assert.AreEqual(ErrorEval.VALUE_INVALID, e.GetErrorEval());
     }
 }
Пример #10
0
 public void TestFailWhenNoDate()
 {
     try
     {
         DateParser.ParseDate("potato");
         Assert.Fail("Shouldn't parse potato!");
     }
     catch (EvaluationException e)
     {
         Assert.AreEqual(ErrorEval.VALUE_INVALID, e.GetErrorEval());
     }
 }
Пример #11
0
        private static void FillMailProperties(Mail mail, BsonDocument sourceEmail, BsonDocument headers)
        {
            var originalId = sourceEmail["_id"].AsObjectId.ToString();
            var body       = sourceEmail["body"];
            var mailBox    = sourceEmail["mailbox"];
            var subFolder  = sourceEmail["subFolder"];
            var subject    = headers["Subject"];
            var dateString = headers["Date"];

            var date = DateParser.ParseDate(dateString.AsString);

            mail.OriginalId = originalId;
            mail.Body       = body.AsString;
            mail.MailBox    = mailBox.AsString;
            mail.SubFolder  = subFolder.AsString;
            mail.Subject    = subject.AsString;
            mail.Date       = date;
        }
Пример #12
0
        public List <Package> GetPackages()
        {
            List <string>  lines    = _envioRepository.GetEnvios();
            List <Package> packages = new List <Package>();

            foreach (string line in lines)
            {
                string[] split           = line.Split(',');
                string   origen          = split[0];
                string   destino         = split[1];
                int      distancia       = int.Parse(split[2]);
                string   empresa         = split[3].ToLower();
                string   medioTransporte = split[4].ToLower();
                DateTime fechaPedido     = DateParser.ParseDate(split[5]);

                if (_factories.TryGetValue(empresa, out IEnvioFactory envioFactory))
                {
                    switch (medioTransporte)
                    {
                    case TiposTransporte.Avion:
                        ManageAvion(packages, origen, destino, distancia, fechaPedido, envioFactory);
                        break;

                    case TiposTransporte.Tren:
                        ManageTren(packages, origen, destino, distancia, fechaPedido, envioFactory);
                        break;

                    case TiposTransporte.Barco:
                        ManageBarco(packages, origen, destino, distancia, fechaPedido, envioFactory);
                        break;
                    }
                }
                else
                {
                    //Null company
                    packages.Add(new Package()
                    {
                        Origen          = origen, Destino = destino, Distancia = distancia, Empresa = null,
                        MedioTransporte = null, FechaRecepcion = fechaPedido, UnSupportedCompany = empresa
                    });
                }
            }
            return(packages);
        }
Пример #13
0
        private void NewDateTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (string.IsNullOrEmpty(NewDateTextBox.Text))
            {
                ConfirmImage.Visibility  = Visibility.Collapsed;
                QuestionImage.Visibility = Visibility.Collapsed;
                return;
            }

            DateTime?d = DateParser.ParseDate(NewDateTextBox.Text);

            if (d != null)
            {
                ConfirmImage.Visibility  = Visibility.Visible;
                QuestionImage.Visibility = Visibility.Collapsed;
                this.Date = d;
            }
            else
            {
                ConfirmImage.Visibility  = Visibility.Collapsed;
                QuestionImage.Visibility = Visibility.Visible;
                this.Date = _openDate;
            }
        }
 protected override DateTime?ConvertBackBase(string input)
 {
     return(DateParser.ParseDate(input));
 }
Пример #15
0
        public void TestShouldParseValidDate()
        {
            TestCases.CultureShim.SetCurrentCulture("en-US");

            Assert.AreEqual(new DateTime(1984, 10, 20), DateParser.ParseDate("1984/10/20"));
        }
Пример #16
0
 public void TestShouldIgnoreTimestamp()
 {
     TestCases.CultureShim.SetCurrentCulture("en-US");
     Assert.AreEqual(new DateTime(1984, 10, 20), DateParser.ParseDate("1984/10/20 12:34:56"));
 }
Пример #17
0
 public void TestShouldIgnoreTimestamp()
 {
     System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
     Assert.AreEqual(new DateTime(1984, 10, 20), DateParser.ParseDate("1984/10/20 12:34:56"));
 }