public void Should_ConvertLongStringDateTimeToDateTime_When_DefaultTypeConverterIsUsed()
        {
            var model = new DateTimeModel();
            var date  = converter.ConvertFromString("01-25-1991 14:30:15.123");

            Assert.AreEqual(date, new DateTime(1991, 1, 25, 14, 30, 15, 123));
        }
        public void Should_ConvertStringDateToDateTime_When_DefaultTypeConverterIsUsed()
        {
            var model = new DateTimeModel();
            var date  = converter.ConvertFromString("1/25/01");

            Assert.AreEqual(date, new DateTime(2001, 1, 25));
        }
예제 #3
0
 public AccountIndexViewModel(Customer customer)
 {
     CustomerId          = customer.Id;
     CustomerName        = NameModel.Create(customer);
     CustomerDateOfBirth = new DateTimeModel(customer.DateOfBirth);
     CustomerHomeAddress = new AddressViewModel(customer.HomeAddress);
 }
예제 #4
0
        public void Extract_DateTime_ShouldMapFromDate()
        {
            // Arrange
            const string value = "20200405";
            RfcErrorInfo errorInfo;

            _interopMock
            .Setup(x => x.GetDate(It.IsAny <IntPtr>(), It.IsAny <string>(), It.IsAny <char[]>(), out errorInfo))
            .Callback(new GetDateCallback((IntPtr dataHandle, string name, char[] buffer, out RfcErrorInfo ei) =>
            {
                Array.Copy(value.ToCharArray(), buffer, value.Length);
                ei = default;
            }));

            // Act
            DateTimeModel result = OutputMapper.Extract <DateTimeModel>(_interopMock.Object, DataHandle);

            // Assert
            _interopMock.Verify(
                x => x.GetDate(DataHandle, "DATETIMEVALUE", It.IsAny <char[]>(), out errorInfo),
                Times.Once);
            _interopMock.Verify(
                x => x.GetDate(DataHandle, "NULLABLEDATETIMEVALUE", It.IsAny <char[]>(), out errorInfo),
                Times.Once);
            result.Should().NotBeNull();
            result.DateTimeValue.Should().Be(new DateTime(2020, 04, 05));
            result.NullableDateTimeValue.Should().Be(new DateTime(2020, 04, 05));
        }
        /// <summary>
        /// Add Date time model
        /// </summary>
        /// <param name="context"></param>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="renderPattern"></param>
        /// <returns></returns>
        public static ContextModel AddDateTime(this ContextModel context, string key, DateTime value, string renderPattern)
        {
            var element = new DateTimeModel(value, renderPattern);

            context.AddItem(key, element);
            return(context);
        }
예제 #6
0
        public void DateTimeModel()
        {
            var dateTime = new DateTimeModel();

            Assert.IsTrue(dateTime != null);
            Assert.IsTrue(dateTime.Value == DateTime.MinValue);
        }
예제 #7
0
        public override ValidatorResult <DateTime> Validate(IBotContext context)
        {
            // Recognize Date
            DateTimeRecognizer dateRecognizer = DateTimeRecognizer.GetInstance(DateTimeOptions.None);
            DateTimeModel      dateModel      = dateRecognizer.GetDateTimeModel("en-US");
            var result = dateModel.Parse(context.Request.AsMessageActivity().Text);

            if (result.Count > 0 && !string.IsNullOrEmpty(result[0].Text))
            {
                try
                {
                    return(new ValidatorResult <DateTime>
                    {
                        Value = DateTime.ParseExact(result[0].Text, "yyyy-MM-dd", CultureInfo.CurrentCulture)
                    });
                }
                catch (Exception e)
                {
                    return(new ValidatorResult <DateTime>
                    {
                        Reason = Constants.DATE_ERROR
                    });
                }
            }
            else
            {
                return(new ValidatorResult <DateTime>
                {
                    Reason = Constants.DATE_ERROR
                });
            }
        }
        public IHttpActionResult UpdateUnavailablePeriod(int id, DateTimeModel model)
        {
            if (!ModelState.IsValid)
            {
                return(InternalServerError(new Exception("Invalid model state")));
            }

            BusySchedules updatedWorkTime;

            try
            {
                Users currentUser = GetUser();
                updatedWorkTime = ScheduleService.UpdateBusyInterval(
                    currentUser.Id,
                    id,
                    model.GetStartDateTime(),
                    model.GetEndDateTime());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }

            return(Ok(updatedWorkTime));
        }
        public ActionResult Submit(DateTimeModel formData)
        {
            DateTime      timeOut       = calculationService.CalculateTimeOut(formData.LastPunch, formData.CurrentHours, formData.DesiredHours);
            DateTimeModel dateTimeModel = calculationService.PopulateModel(timeOut);

            return(PartialView("~/Views/Shared/_outTimeMessage.cshtml", dateTimeModel));
        }
예제 #10
0
        public void DateTimeModel_RanderPattern()
        {
            DateTimeModel DateTimeUT = new DateTimeModel();

            DateTimeUT.RenderPattern = "TEST";
            Assert.IsTrue(DateTimeUT.RenderPattern == "TEST");
        }
예제 #11
0
 public IActionResult GetWeeklyInformation(DateTimeModel model, Guid UserId)
 {
     ProgressInformationModel response = new ProgressInformationModel();
     response.GoalsCompleted = _goalManager.GoalsSolvedThisWeek(UserId);
     response.TasksCompleted = _taskManager.TasksSolvedThisWeek(UserId);
     response.ProgressInMinutes = _progressOnDateManager.GetWeeklyProgress(UserId);
     return Ok(response);
 }
예제 #12
0
        public void DateTimeModel_Value()
        {
            DateTimeModel DateTimeUT = new DateTimeModel();
            DateTime      date       = new DateTime(2008, 5, 1, 8, 30, 52);

            DateTimeUT.Value = date;
            Assert.IsTrue(DateTimeUT.Value == date);
        }
예제 #13
0
        public IEnumerable <Order> GetCurrentOrders(string searchString, string status,
                                                    string paymentType, string start, string end)
        {
            var orders = mySQLOrderService.GetList();

            if (!String.IsNullOrEmpty(searchString))
            {
                int id;
                if (Int32.TryParse(searchString, out id))
                {
                    orders = orders.Where(s => s.Id == id);
                }
                else
                {
                    orders = orders.Where(s => (!string.IsNullOrEmpty(s.ShipName) && s.ShipName.Contains(searchString)) || (!string.IsNullOrEmpty(s.CreatedBy) && s.CreatedBy.Contains(searchString)));
                }
            }

            ViewBag.CurrentFilter = searchString;

            if (!String.IsNullOrEmpty(status))
            {
                orders            = orders.Where(s => s.Status == (OrderStatus)Enum.Parse(typeof(OrderStatus), status));
                ViewBag.DDLStatus = FlowerUtility.SelectListFor((OrderStatus)Enum.Parse(typeof(OrderStatus), status));
            }
            else
            {
                ViewBag.DDLStatus = FlowerUtility.SelectListFor <OrderStatus>();
            }

            if (!String.IsNullOrEmpty(paymentType))
            {
                orders = orders.Where(s => s.PaymentTypeId == (PaymentType)Enum.Parse(typeof(PaymentType), paymentType));
                ViewBag.DDLPaymentType = FlowerUtility.SelectListFor((PaymentType)Enum.Parse(typeof(PaymentType), paymentType));
            }
            else
            {
                ViewBag.DDLPaymentType = FlowerUtility.SelectListFor <PaymentType>();
            }

            var compareDate = new DateTimeModel();

            if (!string.IsNullOrEmpty(start))
            {
                var compareStartDate = Utility.GetNullableDate(start).Value.Date + new TimeSpan(0, 0, 0);
                orders = orders.Where(s => (s.CreatedAt >= compareStartDate));
                compareDate.startDate = compareStartDate;
            }
            if (!string.IsNullOrEmpty(end))
            {
                var compareEndDate = Utility.GetNullableDate(end).Value.Date + new TimeSpan(23, 59, 59);
                orders = orders.Where(s => (s.CreatedAt <= compareEndDate));
                compareDate.endDate = compareEndDate;
            }

            ViewBag.CompareDate = compareDate;
            return(orders);
        }
예제 #14
0
 private void DateTimePickerPage_Close(object sender, DateTimeModel model)
 {
     DateTimePickerDialog.Close -= DateTimePickerPage_Close;
     if (model != null)
     {
         TimeType = model.Type;
         Time     = model.DateTime;
     }
 }
        public DateTimeModel PopulateModel(DateTime clockOutTime)
        {
            DateTimeModel dateTimeModel = new DateTimeModel()
            {
                ClockoutTime = clockOutTime
            };

            return(dateTimeModel);
        }
예제 #16
0
        public ITestActionResult GetBirthdayD(int key)
        {
            DateTimeModel dtm = db.DateTimes.FirstOrDefault(e => e.Id == key);

            if (dtm == null)
            {
                return(NotFound());
            }

            return(Ok(dtm.BirthdayD));
        }
예제 #17
0
        public IHttpActionResult Get(int key)
        {
            DateTimeModel dtm = db.DateTimes.FirstOrDefault(e => e.Id == key);

            if (dtm == null)
            {
                return(NotFound());
            }

            return(Ok(dtm));
        }
예제 #18
0
        public async Task <DateTimeModel> CalculateValueAsync(DateTimeModel model)
        {
            DateTimePickerPart.DateTimeModel = model;
            currentTask = new Task(() => { });
            await currentTask;

            if (okClicked)
            {
                return(DateTimePickerPart.DateTimeModel);
            }
            return(null);
        }
예제 #19
0
        public ITestActionResult Post([FromBody] DateTimeModel dt)
        {
            Assert.NotNull(dt);

            Assert.Equal(99, dt.Id);
            Assert.Equal(new DateTime(2098, 12, 31, 16, 1, 2, DateTimeKind.Unspecified), dt.BirthdayA);
            Assert.Equal(new DateTime(2099, 2, 1, 16, 1, 2), dt.BirthdayB);
            Assert.Single(dt.BirthdayC);
            Assert.Equal(3, dt.BirthdayD.Count);

            return(Created(dt));
        }
예제 #20
0
        public void BasicTest(DateTimeModel model, DateObject baseDateTime, string text, string expectedType, string expectedString, string expectedTimex)
        {
            var results = model.Parse(text, baseDateTime);

            Assert.AreEqual(1, results.Count);
            var result = results.First();

            Assert.AreEqual(expectedString, result.Text);

            var values = result.Resolution["values"] as IEnumerable <Dictionary <string, string> >;

            Assert.AreEqual(expectedType, values.First()["type"]);
            Assert.AreEqual(expectedTimex, values.First()["timex"]);
        }
예제 #21
0
 private void OnTimedEventTime(object sender = null, EventArgs e = null)
 {
     try
     {
         DateTime datetime = DateTime.Now;
         var      model    = new DateTimeModel {
             Date = datetime.ToString("dddd, dd MMMM yyyy", new CultureInfo("ru-RU")), Time = datetime.ToString("HH:mm", new CultureInfo("ru-RU"))
         };
         DateTimeModel = model;
     }
     catch
     {
         var model = new DateTimeModel {
             Date = "An error was occurred", Time = ""
         };
         DateTimeModel = model;
     }
 }
예제 #22
0
        public void BasicTest(DateTimeModel model, DateObject baseDateTime, string text, string expectedType, string expectedString, string expectedTimex, string expectedFuture, string expectedPast)
        {
            var results = model.Parse(text, baseDateTime);

            Assert.AreEqual(1, results.Count);
            var result = results.First();

            Assert.AreEqual(expectedString, result.Text);

            var values = result.Resolution["values"] as IEnumerable <Dictionary <string, string> >;

            Assert.AreEqual(expectedType, values.First()["type"]);
            Assert.AreEqual(expectedTimex, values.First()["timex"]);

            Assert.AreEqual(expectedFuture ?? values.Last()["value"], values.Last()["value"]);

            Assert.AreEqual(expectedPast ?? values.First()["value"], values.First()["value"]);
            TestWriter.Write(TestCulture.Chinese, model, baseDateTime, text, results);
        }
        public IHttpActionResult GetUnvailablePeriods(int userId, [FromUri] DateTimeModel model)
        {
            if (!ModelState.IsValid)
            {
                return(InternalServerError(new Exception("Invalid model state")));
            }

            List <BusySchedules> existingUnvailablePeriods;

            try
            {
                existingUnvailablePeriods = ScheduleService.GetAllBusyIntervalsPerPeriod(
                    userId, model.GetStartDateTime(), model.GetEndDateTime());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }

            return(Ok(existingUnvailablePeriods));
        }
        public IHttpActionResult AddUnavailablePeriod(DateTimeModel model)
        {
            if (!ModelState.IsValid)
            {
                return(InternalServerError(new Exception("Invalid model state")));
            }

            BusySchedules newUnavailablePeriod;

            try
            {
                Users currentUser = GetUser();
                newUnavailablePeriod = ScheduleService.AddBusyInterval(
                    currentUser.Id, model.GetStartDateTime(), model.GetEndDateTime());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }

            return(Ok(newUnavailablePeriod));
        }
예제 #25
0
        public void Extract_NonNullableDateTime_ZeroOrEmptyOrInvalidDate_ShouldMapToMinimumDateTime(string value)
        {
            // Arrange
            RfcErrorInfo errorInfo;

            _interopMock
            .Setup(x => x.GetDate(It.IsAny <IntPtr>(), It.IsAny <string>(), It.IsAny <char[]>(), out errorInfo))
            .Callback(new GetDateCallback((IntPtr dataHandle, string name, char[] buffer, out RfcErrorInfo ei) =>
            {
                Array.Copy(value.ToCharArray(), buffer, value.Length);
                ei = default;
            }));

            // Act
            DateTimeModel result = OutputMapper.Extract <DateTimeModel>(_interopMock.Object, DataHandle);

            // Assert
            _interopMock.Verify(
                x => x.GetDate(DataHandle, "DATETIMEVALUE", It.IsAny <char[]>(), out errorInfo),
                Times.Once);
            result.Should().NotBeNull();
            result.DateTimeValue.Should().Be(DateTime.MinValue);
        }
        // GET: DashBoard
        public ActionResult Index(string start, string end)
        {
            var compareDate = new DateTimeModel();
            var orders      = mySQLOrderService.GetList();

            if (!string.IsNullOrEmpty(start))
            {
                var compareStartDate = Utility.GetNullableDate(start).Value.Date + new TimeSpan(0, 0, 0);
                orders = orders.Where(s => (s.UpdatedAt >= compareStartDate));
                compareDate.startDate = compareStartDate;
            }
            if (!string.IsNullOrEmpty(end))
            {
                var compareEndDate = Utility.GetNullableDate(end).Value.Date + new TimeSpan(23, 59, 59);
                orders = orders.Where(s => (s.UpdatedAt <= compareEndDate));
                compareDate.endDate = compareEndDate;
            }

            ViewBag.CompareDate = compareDate;

            var lstRevenues = mySQLOrderService.GetListRevenues(start, end);
            var dataPoints  = new List <DataPoint>();

            lstRevenues.ForEach(s =>
            {
                if (s.MonthYear == null)
                {
                    dataPoints.Add(new DataPoint(s.TimeGetRevenue, s.TotalRevenue));
                }
                else
                {
                    dataPoints.Add(new DataPoint(s.TotalRevenue, s.MonthYear));
                }
            });
            ViewBag.DataPoints = JsonConvert.SerializeObject(dataPoints);
            return(View());
        }
 public void Should_ThrowFormatException_When_InvalidMonthIsParsed()
 {
     var model = new DateTimeModel();
     var date  = converter.ConvertFromString("13-25-1991 14:30:15.123");
 }
 public void DateTime()
 {
     DateTimeModel DateTime = new DateTimeModel();
 }
 public void RenderPattern()
 {
     DateTimeModel RenderPattern = new DateTimeModel();
 }
예제 #30
0
 public void StringToDateTimeOrNull(DateTimeModel sampleData)
 {
     Assert.Equal(sampleData.Expected, sampleData.Actual.ToDateTimeOrNull());
 }