Пример #1
0
 public BigSelecteController(BigSelecteService bigselecteservice, InviteService inviteservice, DateService dateservice, ValidationService validationservice)
 {
     _bigselecteService = bigselecteservice;
     _inviteService     = inviteservice;
     _dateService       = dateservice;
     _validationService = validationservice;
 }
Пример #2
0
        public async Task Acquire_Job_Where_Due_Time_Is_Greater_Than_Now_Should_Return_Null()
        {
            var date = new DateTime(2017, 1, 2, 3, 4, 5);

            DateService.GetNow().Returns(date);

            var job1 = new JobDescription
            {
                Id      = Guid.NewGuid(),
                State   = ExecutionState.Waiting,
                DueTime = new DateTime(2017, 1, 2, 3, 4, 6),
                Type    = "type"
            };

            var jobs = new List <JobDescription>
            {
                job1
            };

            await Store.AddJobsAsync(jobs);

            var r1 = await Store.AcquireJobAsync();

            Assert.Null(r1);


            date = date.AddSeconds(1);

            DateService.GetNow().Returns(date);

            var r2 = await Store.AcquireJobAsync();

            Assert.Equal(job1.Id, r2.Id);
        }
Пример #3
0
        public async Task Acquire_Job_Should_Update_State()
        {
            //Arrange
            var job1 = new JobDescription
            {
                Id        = Guid.NewGuid(),
                WaitCount = 0,
                State     = ExecutionState.Waiting,
                Type      = "type"
            };

            var jobs = new List <JobDescription>
            {
                job1
            };

            var date = new DateTime(2017, 1, 2, 3, 4, 5);

            DateService.GetNow().Returns(date);

            //Act
            await Store.AddJobsAsync(jobs);

            var result = await Store.AcquireJobAsync();

            //Assert
            Assert.Equal(ExecutionState.Running, result.State);
            Assert.Equal(date, result.UpdatedTime);
        }
Пример #4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            DateService dateService = new DateService();

            TextBox1.Text = dateService.GetLongDateInfoString();
            TextBox2.Text = dateService.GetShortDateInfoString();
        }
Пример #5
0
        public void TestInvalidDateRange()
        {
            DateService ds  = new DateService();
            var         ret = ds.EachDay(new DateTime(2021, 03, 01), new DateTime(2021, 03, 05));

            Assert.NotEqual(TestDays(), ret);
        }
        public void TestValidDateTime()
        {
            DateService ds = new DateService();
            string      s  = ds.DateTimeToString(new DateTime(1970, 1, 1));

            Assert.Equal("1970-01-01", s);
        }
Пример #7
0
        public void TestValidString()
        {
            DateService ds = new DateService();
            DateTime    dt = ds.StringToDateTime("1993-06-02");

            Assert.Equal(new DateTime(1993, 06, 02), dt);
        }
Пример #8
0
        //Get Notifications
        public object GetNotifications(long lastNotifiId, int takeCount)
        {
            try
            {
                bool IsEn          = LanguageService.IsEn;
                var  Notifications = db.GetUserNotifications(AccessToken.GetUserId(), lastNotifiId, takeCount)
                                     .Select(c => new NotificationVM
                {
                    Id            = c.Id,
                    Title         = IsEn ? c.TitleEn : c.TitleAr,
                    DateTimeSince = DateService.CaltDateTimeSince(c.DataTime)
                }).ToList();

                if (Notifications.Count == 0)
                {
                    if (lastNotifiId == 0)
                    {
                        return(new ResponseVM(RequestTypeEnumVM.Info, Token.NoResult));
                    }
                    return(new ResponseVM(RequestTypeEnumVM.Info, Token.NoResultMore));
                }

                return(new ResponseVM(RequestTypeEnumVM.Success, Token.Success, Notifications));
            }
            catch (Exception ex)
            {
                return(new ResponseVM(RequestTypeEnumVM.Error, Token.SomeErrorInServer, ex));
            }
        }
Пример #9
0
        public object GetUsers(int take, int skip, int?countryId, int?accountTypeId, bool?isBlocked, DateTime?createDateFrom, DateTime?createDateTo)
        {
            try
            {
                var Result = db.SelectUsersByFilter(skip, take, accountTypeId, isBlocked, countryId, createDateFrom, createDateTo).ToList().Select(c => new
                {
                    c.Id,
                    CreateDate = DateService.GetDateTimeByCulture(c.CreateDate),
                    c.Email,
                    c.FullName,
                    c.Image,
                    c.IsBlocked,
                    Country = LanguageService.IsEn ? c.NameEn : c.NameAr,
                    c.PhoneNumber,
                    c.UserName
                }).ToList();

                if (Result.Count == 0)
                {
                    if (skip == 0)
                    {
                        return(new ResponseVM(RequestTypeEnumVM.Info, Token.NoResult));
                    }
                    return(new ResponseVM(RequestTypeEnumVM.Info, Token.NoResultMore));
                }
                return(new ResponseVM(RequestTypeEnumVM.Success, Token.Success, Result));
            }
            catch (Exception ex)
            {
                return(new ResponseVM(RequestTypeEnumVM.Error, Token.SomeErrorInServer, ex));
            }
        }
Пример #10
0
        private void GetDatesBtn_Click(object sender, EventArgs e)
        {
            DateService dateService = new DateService();

            textBox1.Text = dateService.GetLongDateInfoString();
            textBox2.Text = dateService.GetShortDateInfoString();
        }
Пример #11
0
        public DaySelectorViewModel(INavigation navigation, IRepoManager repoManager, DateService dateService)
        {
            _navigation  = navigation ?? throw new ArgumentNullException(nameof(navigation));
            _repoManager = repoManager ?? throw new ArgumentNullException(nameof(repoManager));
            _dateService = dateService ?? throw new ArgumentNullException(nameof(dateService));

            DataObjects.StopVisit stopVisit = repoManager.StopVisitRepository.First();

            DateTimeOffset firstDate = DateTime.Today;

            if (stopVisit != null)
            {
                firstDate = stopVisit.BeginTimestamp;
            }

            double days = (DateTime.Today - firstDate.Date).TotalDays;

            for (int i = 0; i <= days; i++)
            {
                DateTime currentDate = DateTime.Today.AddDays(-1 * i);
                Items.Add(new Day()
                {
                    Time = currentDate
                });
            }

            CancelCommand = new Command(async() =>
            {
                Analytics.TrackEvent("Cancel dayselector clicked");
                await _navigation.PopModalAsync();
            });
        }
Пример #12
0
        public async Task <PlanningApp> AppendGenerator(PlanningApp planningApp, int SequenceId, int NewGeneratorId)
        {
            var currentDate = DateService.GetCurrentDate();
            PlanningAppState newPlanningAppState = new PlanningAppState();

            var generator = await StateInitialiserRepository.GetStateInitialiser(NewGeneratorId);

            var generatorExists = planningApp.OrderedPlanningAppStates.Any(ps => ps.GeneratorOrder == SequenceId);

            //increase SequenceId of all future generators ad insert new one
            if (generatorExists)
            {
                planningApp.PlanningAppStates
                .Where(g => g.GeneratorOrder >= SequenceId)
                .Select(g => { g.GeneratorOrder++; return(g); })
                .ToList();
            }

            foreach (var state in generator.OrderedStates)
            {
                InsertPlanningState(planningApp, SequenceId, generator, state);
            }
            UpdateDueByDates(planningApp);
            return(planningApp);
        }
        private void OnGetDate(object sender, RoutedEventArgs e)
        {
            var dateService = new DateService();

            text1.Text = dateService.GetLongDateInfoString();
            text2.Text = dateService.GetShortDateInfoString();
        }
Пример #14
0
        public void TestGetDateDiffInDays()
        {
            Date startDate1 = new Date(27, 12, 2015);
            Date endDate1   = new Date(27, 12, 2016);

            Date startDate2 = new Date(7, 3, 2015);
            Date endDate2   = new Date(27, 12, 2017);

            Date startDate3 = new Date(27, 2, 2015);
            Date endDate3   = new Date(27, 3, 2017);

            Date startDate4 = new Date(27, 3, 2015);
            Date endDate4   = new Date(7, 12, 2017);

            Date startDate5 = new Date(27, 3, 2015);
            Date endDate5   = new Date(7, 12, 2020);

            Date startDate6 = new Date(27, 3, 2015);
            Date endDate6   = new Date(11, 1, 2016);



            Assert.AreEqual(366, DateService.GetDateDiffInDays(startDate1, endDate1));
            Assert.AreEqual(1026, DateService.GetDateDiffInDays(startDate2, endDate2));
            Assert.AreEqual(759, DateService.GetDateDiffInDays(startDate3, endDate3));
            Assert.AreEqual(986, DateService.GetDateDiffInDays(startDate4, endDate4));
            Assert.AreEqual(2082, DateService.GetDateDiffInDays(startDate5, endDate5));
            Assert.AreEqual(290, DateService.GetDateDiffInDays(startDate6, endDate6));
        }
Пример #15
0
        public CmnPopUp(string FormHeaderText, bool blnDefaultSrhColType, int iHeight, int iWidth)
        {
            InitializeComponent();

            this.mainVB    = new JVBCommon();
            this.dml       = new DMLService();
            this.cmn       = new CommonService();
            this.dtService = new DateService();
            this.dsData    = new DataSet();

            this.Text     = FormHeaderText;
            blnDefaultCol = blnDefaultSrhColType;

            // Resizing the Help Grid
            // Height
            this.Height = iHeight;
            this.grpHelpDisplay.Height = this.Height - (this.grpHelpCriteria.Height + 40);
            this.dgrdHelpGrid.Height   = this.grpHelpDisplay.Height - 10;
            this.grpHelpCriteria.Top   = this.dgrdHelpGrid.Height + 10;

            // Width
            this.Width = iWidth;
            this.grpHelpDisplay.Width  = this.Width - 30;
            this.dgrdHelpGrid.Width    = this.grpHelpDisplay.Width - 2;
            this.grpHelpCriteria.Width = this.Width - 30;

            pnlRbn.Left           = this.grpHelpCriteria.Width - 340;
            txtSearchColumn.Width = this.grpHelpCriteria.Width - 225;

            BtnCancel.Left = this.grpHelpCriteria.Width - 82;
        }
Пример #16
0
        public int AddTotalizator(int organaizerId, int stage, string tTitle, PointsAnalysisView tPoints, string tAccess)
        {
            bool     isPublic  = true;
            DateTime ValidDate = DateService.getValidDate(stage, context);

            if (tAccess == "Private")
            {
                isPublic = false;
            }
            int totalizatorId = GetNextIndex();
            var pA            = new PointsAnalysis()
            {
                Full          = tPoints.Full,
                GoalDif       = tPoints.GoalDif,
                JustWinner    = tPoints.JustWinner,
                TotalizatorId = totalizatorId
            };

            context.PointsAnalysis.Add(pA);
            var totalizator = new Totalizator()
            {
                Name          = tTitle,
                TotalizatorId = totalizatorId,
                OrganaizerId  = organaizerId,
                StageId       = stage,
                Validity      = ValidDate,
                isPublic      = isPublic
            };

            context.Totalizators.Add(totalizator);
            context.SaveChanges();
            return(totalizatorId);
        }
Пример #17
0
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var ticket = await _context.Tickets.FindAsync(id);

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

            var           games          = _context.Games.OrderBy(g => g.Date).Include(g => g.HomeTeam).Include(g => g.AwayTeam).ToList();
            List <object> formattedGames = new List <object>();

            foreach (var game in games)
            {
                formattedGames.Add(new
                {
                    Id   = game.Id,
                    Name = DateService.GetFormattedGameDate(game.AwayTeam.Name, game.HomeTeam.Name, game.Date)
                });
            }
            ViewData["GameId"] = new SelectList(formattedGames, "Id", "Name", ticket.GameId);
            return(View(ticket));
        }
        private static AccountActivityOverViewVeiwModel CreateViewModel(IOrderedEnumerable <AccountActivitiesViewModel> allActivities, int year, int month)
        {
            var runningTotal = 0d;

            foreach (var activity in allActivities)
            {
                if (!activity.IsTransfer)
                {
                    runningTotal += activity.Amount;
                }
                activity.RunningTotal = runningTotal;
            }

            var allActivitiesDateDesending = allActivities.Reverse().ToList();

            var accountActivityOverViewVeiwModel = new AccountActivityOverViewVeiwModel(allActivitiesDateDesending)
            {
                MoneyIn       = allActivities.Where(x => !x.IsTransfer).Sum(x => x.Amount > 0 ? x.Amount : 0),
                MoneyOut      = allActivities.Where(x => !x.IsTransfer).Sum(x => x.Amount < 0 ? x.Amount : 0),
                PreviousMonth = DateService.PreviousMonth(year, month),
                PreviousYear  = DateService.PreviousYear(year, month),
                NextMonth     = DateService.NextMonth(year, month),
                NextYear      = DateService.NextYear(year, month),
                StatementDate = DateService.GetMonthYearDate(year, month)
            };

            return(accountActivityOverViewVeiwModel);
        }
Пример #19
0
        private static bool IsDateInInterval(BsonValue eventStart)
        {
            var startDate = DateService.GetCurrentBson;
            var endDate   = DateService.ToBson(DateTime.Now.AddDays(10));

            return(eventStart > startDate && eventStart < endDate);
        }
Пример #20
0
        public IUserEvent InitializeFromEvent(IEvent myEvent)
        {
            EventId       = myEvent.Id;
            StartDateTime = myEvent.StartDateTime;
            Joined        = DateService.ToBson(DateTime.Now);

            return(this);
        }
Пример #21
0
        private static bool IsDateInPastInterval(BsonValue eventStart, int intervalStart, int intervalEnd)
        {
            //TODO: tun this
            var endDate   = DateService.ToBson(DateTime.Now.AddHours(intervalStart * -1));
            var startDate = DateService.ToBson(DateTime.Now.AddHours(intervalEnd * -1));

            return(eventStart > startDate && eventStart < endDate);
        }
Пример #22
0
 public LoginViewModel()
 {
     navigationService = new NavigationService();
     dialogService     = new DialogService();
     apiService        = new ApiService();
     dateService       = new DateService();
     IsRemembered      = true;
 }
Пример #23
0
        public bool ValidateDateFormat(string day, out string errorMessage)
        {
            errorMessage = "";
            // 날짜는 1-31사이 검증
            if (!DateService.DateBetween(day))
            {
                errorMessage = "비정상적인 날짜입니다. 다시 한번 확인해주세요.";
                return(false);
            }

            // 오늘 날짜보다 적은 날짜이면 다음달로 본다.
            new DateTime();
            DateService service   = new DateService();
            var         today     = DateTime.Today;
            var         thisYear  = today.ToString("yyyy");
            var         thisMonth = today.ToString("MM");
            var         input     = service.GetConvertDate(day); //00~31 << 형태로 변환.

            var dayoff_str = thisYear + thisMonth + input;

            DateTime dayoff;

            if (!DateTime.TryParseExact(dayoff_str, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None, out dayoff))
            {
                //잘못된 날짜 입력시.ex) 4월 31일.
                var printDay   = DateService.GetConvertPrintDate(input);
                var printMonth = DateService.GetConvertPrintMonth(thisMonth);
                errorMessage = printMonth + " " + printDay + "은 뭔가 잘못된 입력된것 같은데요? 날짜 다시 한번 확인해주세요.";
                return(false);
            }

            var result = DateTime.Compare(today, dayoff);

            if (result > 0)
            {
                //다음달로 리턴.
                var nextMonth = DateTime.Today.AddMonths(1).ToString("yyyyMM") + input;
                // 다음달이 유효하지않다면 ex)2월 31일 같은 것
                if (!DateTime.TryParseExact(nextMonth, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None, out dayoff))
                {
                    var month    = DateService.GetConvertPrintMonth(dayoff.ToString("MM"));
                    var inputDay = dayoff.ToString("dd");
                    errorMessage = month + " " + day + "이 맞나요? 그런 날짜는 존재하지 않아요. 다시 확인해보세요.";
                    return(false);
                }
            }

            // TODO: 요일 검증. (토요일, 일요일은 휴가를 사용할 필요가 없다.)
            if ((int)dayoff.DayOfWeek == 0 || (int)dayoff.DayOfWeek == 6) //0~6 일요일 - 토요일
            {
                var month = DateService.GetConvertPrintMonth(dayoff.ToString("MM"));
                errorMessage = month + " " + day + "은 주말입니다. 그냥 쉬시고 다른날짜를 입력해 주세요~";
                return(false);
            }
            // TODO: 공휴일 검증. (설날, 추석, 어린이날 등), DB로 공휴일 관리를 해야할듯 싶습니다. 이건 일단 PASS

            return(true);
        }
Пример #24
0
        public void TestIsLeapYear()
        {
            // Known facts: 2020 is a leap year, and 2015 isn't.
            int leapYear    = 2020;
            int nonLeapYear = 2015;

            Assert.AreEqual(true, DateService.IsLeapYear(leapYear));
            Assert.AreEqual(false, DateService.IsLeapYear(nonLeapYear));
        }
Пример #25
0
 public object GetSampleEmailsSubscriptionInformation(SelectEmailsSubscriptionsByFilter_Result c)
 {
     return(new
     {
         Id = c.Id,
         Email = c.Email,
         CreatedDate = DateService.GetDateTimeByCulture(c.CreateDateTime),
     });
 }
Пример #26
0
        public void Prepare()
        {
            var optionsBuilder = new DbContextOptionsBuilder <ApplicationContext>();

            optionsBuilder.UseInMemoryDatabase("testdb");
            var _dbContext = new ApplicationContext(optionsBuilder.Options);

            service = new DateService(_dbContext);
        }
Пример #27
0
        private void lvFundName_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Fund cfund = lvFundName.SelectedItem as Fund;

            ntWorkModel             = GetFundEquityInfo.Instance.Info(cfund.CODE, DateService.ThisTimeLastYear(), DateTime.Now);
            lvLatestNet.ItemsSource = ntWorkModel;
            getMyDetail.GetGuessInfo(GetFundEquityInfo.Instance.InfoEqLst(ntWorkModel));
            lvReferInfo.ItemsSource = getMyDetail.Datas;
        }
Пример #28
0
        public TrnPartySave()
        {
            InitializeComponent();

            dmlService = new DMLService();
            cmnService = new CommonService();
            dtService  = new DateService();
            mainVB     = new JVBCommon();
        }
Пример #29
0
 public IUserEvent UserEvent(IEvent uEvent)
 {
     return(new UserEvent
     {
         EventId = uEvent.Id,
         StartDateTime = uEvent.StartDateTime,
         Joined = DateService.ToBson(DateTime.Now)
     });
 }
        public EasyTimetableMainPage()
        {
            InitializeComponent();
            tempIDList      = new List <int>();
            today           = DateService.GetTodayDateIndex();
            dayofweek       = DateService.GetTodayDayofWeek(today);
            todayTitle.Text = dayofweek + " (" + DateTime.Today.Month + "." + DateTime.Today.Day + ")";

            _database = new DatabaseService().SQLiteDatabase;
        }