Пример #1
0
        public static bool IsNotInFutureMonthYear(this MonthYearModel monthYearModel)
        {
            var dateTimeNow       = DateTime.UtcNow;
            var futureDateAndTime = new DateTime(dateTimeNow.Year, dateTimeNow.AddMonths(1).Month, 1);

            return(monthYearModel.Date.Value < futureDateAndTime);
        }
Пример #2
0
 public void Arrange()
 {
     _monthYear = new MonthYearModel("")
     {
         Month = 3, Year = 2020
     };
 }
Пример #3
0
        /// <summary>
        /// Method Name     : Validation
        /// Author          : Sanket Prajapati
        /// Creation Date   : 13 jan 2018
        /// Purpose         : Use for validation
        /// Revision        :
        /// </summary>
        private string Validation()
        {
            MonthYearModel yearValue    = yearList.FirstOrDefault(rc => rc.Year == spinnerExpYear.SelectedItem.ToString());
            MonthYearModel monthValue   = monthList.FirstOrDefault(rc => rc.Month == spinnerExpMonth.SelectedItem.ToString());
            string         errormessage = string.Empty;

            CardTypeInfoModel cardTypeInfoModel = UtilityPCL.GetCardTypes().FirstOrDefault(rc => rc.CardType == cardType);

            if (string.IsNullOrEmpty(txtNameofCardHolder.Text))
            {
                errormessage = StringResource.msgNameofCardholderisRequired;
            }
            else if (!string.IsNullOrEmpty(txtNameofCardHolder.Text.Trim()))
            {
                errormessage = ValidFullName();
                if (string.IsNullOrEmpty(errormessage))
                {
                    if (string.IsNullOrEmpty(txtCardNumber.Text))
                    {
                        errormessage = StringResource.msgCardNumberIsRequired;
                    }
                    else
                    {
                        errormessage = validExpDateAndCardnumber(yearValue, monthValue, cardTypeInfoModel);
                    }
                }
            }
            return(errormessage);
        }
        public static bool IsNotInFutureMonthYear(this MonthYearModel monthYearModel, DateTime nowDateTime)
        {
            var plusOneMonth      = nowDateTime.AddMonths(1);
            var futureDateAndTime = new DateTime(plusOneMonth.Year, plusOneMonth.Month, 1);

            return(monthYearModel.Date.Value < futureDateAndTime);
        }
Пример #5
0
        public void DateTime_WithMonthPartChangedAfterConstruction_ShouldMakeNewDateAvailable()
        {
            var date = new MonthYearModel("122019");

            date.Month = 10;
            Assert.AreEqual(new DateTime(2019, 10, 1), date.Date);
        }
Пример #6
0
        public void Arrange()
        {
            _mockCommitmentsApiClient = new Mock <ICommitmentsApiClient>();
            _mockModelMapper          = new Mock <IModelMapper>();

            var autoFixture = new Fixture();

            _viewModel = autoFixture.Create <ChangeVersionViewModel>();

            var baseDate    = DateTime.Now;
            var startDate   = new MonthYearModel(baseDate.ToString("MMyyyy"));
            var endDate     = new MonthYearModel(baseDate.AddYears(2).ToString("MMyyyy"));
            var dateOfBirth = new MonthYearModel(baseDate.AddYears(-18).ToString("MMyyyy"));

            _editRequestViewModel = autoFixture.Build <EditApprenticeshipRequestViewModel>()
                                    .With(x => x.StartDate, startDate)
                                    .With(x => x.EndDate, endDate)
                                    .With(x => x.DateOfBirth, dateOfBirth)
                                    .Create();

            _mockModelMapper.Setup(m => m.Map <EditApprenticeshipRequestViewModel>(It.IsAny <ChangeVersionViewModel>()))
            .ReturnsAsync(_editRequestViewModel);

            _controller = new ApprenticeController(_mockModelMapper.Object,
                                                   Mock.Of <ICookieStorageService <IndexRequest> >(),
                                                   _mockCommitmentsApiClient.Object,
                                                   Mock.Of <ILogger <ApprenticeController> >());

            _controller.TempData = new TempDataDictionary(new Mock <HttpContext>().Object, new Mock <ITempDataProvider>().Object);
        }
Пример #7
0
        public async Task <ConfirmViewModel> Map(ConfirmRequest source)
        {
            try
            {
                var data = await  GetApprenticeshipData(source.ApprenticeshipId, source.AccountLegalEntityId);

                var newStartDate = new MonthYearModel(source.StartDate);
                var newEndDate   = new MonthYearModel(source.EndDate);

                return(new ConfirmViewModel
                {
                    ApprenticeshipHashedId = source.ApprenticeshipHashedId,
                    AccountLegalEntityPublicHashedId = source.EmployerAccountLegalEntityPublicHashedId,
                    OldEmployerName = data.Apprenticeship.EmployerName,
                    ApprenticeName = $"{data.Apprenticeship.FirstName} {data.Apprenticeship.LastName}",
                    StopDate = data.Apprenticeship.StopDate.Value,
                    OldStartDate = data.Apprenticeship.StartDate,
                    OldEndDate = data.Apprenticeship.EndDate,
                    OldPrice = decimal.ToInt32(data.PriceEpisodes.PriceEpisodes.GetPrice()),
                    NewEmployerName = data.AccountLegalEntity.LegalEntityName,
                    NewStartDate = newStartDate.MonthYear,
                    NewEndDate = newEndDate.MonthYear,
                    NewPrice = source.Price,
                    FundingBandCap = GetFundingBandCap(data.TrainingProgramme, newStartDate.Date)
                });
            }
            catch (Exception e)
            {
                _logger.LogError($"Error mapping apprenticeshipId {source.ApprenticeshipId} to model {nameof(ConfirmViewModel)}", e);
                throw;
            }
        }
Пример #8
0
        public async Task ThenNewEndDateIsMapped()
        {
            var result = await _fixture.Map();

            var expectedEndDate = new MonthYearModel(_fixture.request.EndDate);

            Assert.AreEqual(expectedEndDate.MonthYear, result.NewEndDate);
        }
        public void AndEndDateIsEmpty_ThenShouldHaveError()
        {
            MonthYearModel endDate = new MonthYearModel("");
            var            model   = new EndDateViewModel {
                EndDate = endDate
            };

            AssertValidationResult(request => request.StartDate, model, false);
        }
Пример #10
0
        public void AndStartDateIsEmpty_ThenShouldHaveError()
        {
            DateTime?      stopDate  = new DateTime(2019, 1, 1);
            MonthYearModel startDate = new MonthYearModel("");
            var            model     = new StartDateViewModel {
                StartDate = startDate, StopDate = stopDate
            };

            AssertValidationResult(request => request.StartDate, model, false);
        }
Пример #11
0
        public void AndStartDateIsComparedAgainstAcademicYear_ThenShouldGetExpectedResult(string startDate, bool expected)
        {
            DateTime?      stopDate = new DateTime(2020, 1, 1);
            MonthYearModel start    = new MonthYearModel(startDate);
            var            model    = new StartDateViewModel {
                StartDate = start, StopDate = stopDate
            };

            AssertValidationResult(request => request.StartDate, model, expected);
        }
Пример #12
0
 public static bool IsValidMonthYear(this string monthYear)
 {
     try
     {
         MonthYearModel dateModel = new MonthYearModel(monthYear);
         return(dateModel.IsValid);
     }
     catch (ArgumentException)
     {
         return(false);
     }
 }
        public void AndEndDateIsInvalid_ThenShouldHaveError(int?year, int?month)
        {
            MonthYearModel endDate = new MonthYearModel("");

            endDate.Month = month;
            endDate.Year  = year;
            var model = new EndDateViewModel {
                EndDate = endDate
            };

            AssertValidationResult(request => request.StartDate, model, false);
        }
Пример #14
0
        public void AndStartDateIsInvalid_ThenShouldHaveError(int?year, int?month)
        {
            DateTime?      stopDate  = new DateTime(2019, 1, 1);
            MonthYearModel startDate = new MonthYearModel("");

            startDate.Month = month;
            startDate.Year  = year;
            var model = new StartDateViewModel {
                StartDate = startDate, StopDate = stopDate
            };

            AssertValidationResult(request => request.StartDate, model, false);
        }
Пример #15
0
        public void AndStartDateIsValid_ThenShouldNotHaveError()
        {
            DateTime?      stopDate  = new DateTime(2019, 1, 1);
            MonthYearModel startDate = new MonthYearModel("");

            startDate.Month = 1;
            startDate.Year  = 2020;
            var model = new StartDateViewModel {
                StartDate = startDate, StopDate = stopDate
            };

            AssertValidationResult(request => request.StartDate, model, true);
        }
Пример #16
0
        public static List <MonthYearModel> BindMonthList()
        {
            MonthYearModel        monthYearModel;
            List <MonthYearModel> monthList;

            monthList = new List <MonthYearModel>();
            for (int i = 1; i <= 12; i++)
            {
                monthYearModel            = new MonthYearModel();
                monthYearModel.Month      = i.ToString("00");
                monthYearModel.Monthindex = i;
                monthList.Add(monthYearModel);
            }
            return(monthList);
        }
Пример #17
0
        public void WhenDateTimeIsInFuture_IsNotInFutureMonthYear_ReturnsFalse(string nowDateString, string proposedStopDateString, bool isValid)
        {
            var nowDate = DateTime.ParseExact(nowDateString,
                                              "dd/MM/yyyy",
                                              CultureInfo.CurrentCulture);

            var proposedStopDate = DateTime.ParseExact(proposedStopDateString,
                                                       "dd/MM/yyyy",
                                                       CultureInfo.CurrentCulture);

            var monthYear = new MonthYearModel(proposedStopDate.ToString("MMyyyy"));

            var actualResult = monthYear.IsNotInFutureMonthYear(nowDate);

            Assert.AreEqual(isValid, actualResult);
        }
Пример #18
0
        public static List <MonthYearModel> BindYearList()
        {
            MonthYearModel        monthYearModel;
            List <MonthYearModel> yearList;

            yearList = new List <MonthYearModel>();
            int year = DateTime.Now.Year;

            for (int i = 0; i <= 40; i++)
            {
                int addYear = year + i;
                monthYearModel           = new MonthYearModel();
                monthYearModel.Year      = addYear.ToString();
                monthYearModel.Yearindex = addYear;
                yearList.Add(monthYearModel);
            }
            return(yearList);
        }
Пример #19
0
        public static List <FullScheduleModel> SelectFor(MonthYearModel monthYear)
        {
            try
            {
                using (AppContext db = new AppContext())
                {
                    var schedules = db.ScheduleSet.Where(year => year.LectureDateTimeStart.Year == monthYear.Year)
                                    .Where(month => month.LectureDateTimeStart.Month == monthYear.Month)
                                    .ToList();

                    return(Convert(schedules));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
Пример #20
0
        /// Method Name     : BindSpinerMonth
        /// Author          : Sanket Prajapati
        /// Creation Date   : 2 Dec 2017
        /// Purpose         : Use fort bind month
        /// Revision        :
        /// </summary>
        private void BindSpinerMonth()
        {
            List <String> valutionList = MonthList();

            if (valutionList.Count > 0)
            {
                var monthAdapter = new ArrayAdapter <string>(Activity, Android.Resource.Layout.SimpleSpinnerItem, valutionList);
                monthAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
                spinnerExpMonth.Adapter = monthAdapter;
                string         currentMonth   = DateTime.Now.Month.ToString("00");
                MonthYearModel monthYearModel = monthList.FirstOrDefault(rc => rc.Month == currentMonth);
                if (monthYearModel.Monthindex == 0)
                {
                    spinnerExpMonth.SetSelection(monthYearModel.Monthindex);
                }
                else
                {
                    spinnerExpMonth.SetSelection(monthYearModel.Monthindex - 1);
                }
            }
        }
Пример #21
0
        public ContentResult GetSchedule(MonthYearModel monthYear)
        {
            if (ModelState.IsValid)
            {
                var fullSchedule = SelectSchedule.SelectFor(monthYear);

                return(new ContentResult
                {
                    Content = JsonSerializer.Serialize(fullSchedule),
                    ContentType = "application/json",
                    StatusCode = (int)HttpStatusCode.OK
                });
            }
            else
            {
                return(new ContentResult
                {
                    StatusCode = (int)HttpStatusCode.InternalServerError
                });
            }
        }
        public void Arrange()
        {
            var autoFixture = new Fixture();

            _viewModel = autoFixture.Create <ChangeVersionViewModel>();

            var baseDate    = DateTime.Now;
            var startDate   = new MonthYearModel(baseDate.ToString("MMyyyy"));
            var endDate     = new MonthYearModel(baseDate.AddYears(2).ToString("MMyyyy"));
            var dateOfBirth = new MonthYearModel(baseDate.AddYears(-18).ToString("MMyyyy"));

            _editRequestViewModel = autoFixture.Build <EditApprenticeshipRequestViewModel>()
                                    .With(x => x.StartDate, startDate)
                                    .With(x => x.EndDate, endDate)
                                    .With(x => x.DateOfBirth, dateOfBirth)
                                    .Create();

            _fixture = new WhenPostingChangeVersionFixture();

            _fixture.SetUpMockMapper(_editRequestViewModel);
        }
Пример #23
0
        /// <summary>
        /// Method Name     : Validation
        /// Author          : Sanket Prajapati
        /// Creation Date   : 13 jan 2018
        /// Purpose         : Use for validation
        /// Revision        :
        /// </summary>
        private string validExpDateAndCardnumber(MonthYearModel yearValue, MonthYearModel monthValue, CardTypeInfoModel cardTypeInfoModel)
        {
            string errormessage = string.Empty;
            int    month        = DateTime.Now.Month;
            int    year         = DateTime.Now.Year;
            string cardNumber   = txtCardNumber.Text.Replace("-", "").Trim();

            if (cardTypeInfoModel == null || (cardTypeInfoModel.CardNumberLength != cardNumber.Length))
            {
                errormessage = StringResource.msgInvalidCard;
            }
            else if (year > yearValue.Yearindex || (year == yearValue.Yearindex && month > monthValue.Monthindex))
            {
                errormessage = StringResource.msgExpiredateValidation;
            }
            else if (string.IsNullOrEmpty(txtCVV.Text))
            {
                errormessage = StringResource.msgCVVIsRequired;
            }

            return(errormessage);
        }
Пример #24
0
 public static bool IsBeforeMonthYearOfDateTime(this MonthYearModel monthYearModel, DateTime datetime)
 {
     return(monthYearModel.Date.Value < new DateTime(datetime.Year, datetime.Month, 1));
 }
Пример #25
0
 public static bool IsEqualToOrAfterMonthYearOfDateTime(this MonthYearModel monthYearModel, DateTime dateTime)
 {
     return(monthYearModel.Date.Value >= new DateTime(dateTime.Year, dateTime.Month, 1));
 }
 public DraftApprenticeshipViewModel()
 {
     DateOfBirth = new DateModel();
     StartDate   = new MonthYearModel("");
     EndDate     = new MonthYearModel("");
 }
Пример #27
0
 public EndDateViewModel()
 {
     EndDate = new MonthYearModel("");
 }
 public StartDateViewModel()
 {
     StartDate = new MonthYearModel("");
 }
 public WhatIsTheNewStartDateViewModel()
 {
     NewStartDate = new MonthYearModel("");
 }
 public EditApprenticeshipRequestViewModel()
 {
     DateOfBirth = new DateModel();
     StartDate   = new MonthYearModel("");
     EndDate     = new MonthYearModel("");
 }