Ejemplo n.º 1
0
        public async Task <IActionResult> configuredays(string weekday)
        {
            try
            {
                WeekDaysKeyValue weekDaysKeyValue = new WeekDaysKeyValue();
                weekDaysKeyValue = await ReadAndWriteFile.ReadFileAsync <WeekDaysKeyValue>(Environment.CurrentDirectory + @"\wwwroot\Data\weekDays.json");

                bool a = true;
                if (weekDaysKeyValue.weekDays.ContainsKey(weekday))
                {
                    string value = weekDaysKeyValue.weekDays[weekday];
                    if (value == "true")
                    {
                        weekDaysKeyValue.weekDays[weekday] = "false";
                        a = false;
                    }
                    else
                    {
                        weekDaysKeyValue.weekDays[weekday] = "true";
                        a = true;
                    }
                    await ReadAndWriteFile.WriteFileAsync <WeekDaysKeyValue>(weekDaysKeyValue, Environment.CurrentDirectory + @"\wwwroot\Data\weekDays.json");
                }
                return(Json(a));
            }
            catch (Exception)
            {
                return(View(nameof(Index)));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> NoteAndCheckDate([FromRoute] string culture, DateTime date)
        {
            WeekDaysKeyValue weekDaysKeyValue = new WeekDaysKeyValue();

            try
            {
                weekDaysKeyValue = await ReadAndWriteFile.ReadFileAsync <WeekDaysKeyValue>(Environment.CurrentDirectory + @"\wwwroot\Data\weekDays.json");

                int count = 0;
                if ((date - DateTime.Now).Days <= weekDaysKeyValue.limit && date > DateTime.Now)
                {
                    foreach (var item in weekDaysKeyValue.weekDays)
                    {
                        count++;
                        if (count == ((int)date.DayOfWeek + 1))
                        {
                            if (item.Value.ToLower() == "true")
                            {
                                int?userId  = HttpContext.Session.GetInt32("user");
                                var holiday = await _context.Holidays.Where(m => m.Date.Year == date.Year && m.Date.Month == date.Month && m.Date.Day == date.Day).FirstOrDefaultAsync();

                                if (holiday != null)
                                {
                                    throw new WeekDayException("this day is holiday");
                                }
                                var lawyer = await _context.Schedules.Where(m => m.TeammemberId == userId && m.Date == date).FirstOrDefaultAsync();

                                if (lawyer != null)
                                {
                                    throw new WeekDayException("Lawyer is busyu this time");
                                }
                                HttpContext.Session.SetString("date", date.ToString());
                                return(Json(200));
                            }
                            else
                            {
                                throw new WeekDayException("we dont have time");
                            }
                        }
                        continue;
                    }
                }
                else
                {
                    throw new WeekDayException($"you cannot select {weekDaysKeyValue.limit}");
                }
                throw new WeekDayException("we dont have time");
            }
            catch (WeekDayException ex)
            {
                return(Json(ex.Message));
            }
            catch (Exception)
            {
                return(Json("something went wrong please try again later"));
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Thread smallData = new Thread(ReadAndWriteFile.ReadSmallFileData);

            smallData.Start();
            smallData.Join();
            ReadAndWriteFile.Write(outputSmallFile);

            Thread bigData = new Thread(ReadAndWriteFile.ReadBigFileData);

            bigData.Start();
            bigData.Join();
            ReadAndWriteFile.Write(outputBigFile);

            Console.ReadKey();
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> GetweekDays([FromQuery] DateTime date)
        {
            try
            {
                WeekDaysKeyValue weekDaysKeyValue = await ReadAndWriteFile.ReadFileAsync <WeekDaysKeyValue>(Environment.CurrentDirectory + @"\wwwroot\Data\weekDays.json");

                List <DateTime> dates = await _context.Holidays.Where(m => m.Date.Year == date.Year && m.Date.Month == date.Month).Select(x => x.Date).ToListAsync();

                return(Json(new CalendarDayViewModel
                {
                    weekDays = weekDaysKeyValue.weekDays,
                    Dates = dates
                }));
            }
            catch (Exception)
            {
                return(View(nameof(Index)));
            }
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Index()
        {
            try
            {
                int?languageId = DbContextService.GetLanguageIdByShortName(_context);
                IEnumerable <TeamMemberDto> teamMembers = await _context.GetTeamMembersViewAsync();

                WeekDaysKeyValue weekDaysKeyValue = new WeekDaysKeyValue();
                weekDaysKeyValue = await ReadAndWriteFile.ReadFileAsync <WeekDaysKeyValue>(Environment.CurrentDirectory + @"\wwwroot\Data\weekDays.json");

                return(View(new CalendarIndexViewModel
                {
                    teamMembers = teamMembers.Where(m => m.LanguageId == languageId),
                    weekDaysKeyValue = weekDaysKeyValue
                }
                            ));
            }
            catch (Exception)
            {
                return(Redirect(nameof(Index)));
            }
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> configureLimit(int day)
        {
            try
            {
                if (day != 0)
                {
                    var data = await ReadAndWriteFile.ReadFileAsync <WeekDaysKeyValue>(Environment.CurrentDirectory + @"\wwwroot\Data\weekDays.json");

                    data.limit = day;
                    await ReadAndWriteFile.WriteFileAsync <WeekDaysKeyValue>(data, Environment.CurrentDirectory + @"\wwwroot\Data\weekDays.json");

                    return(Json(day));
                }
                else
                {
                    return(Json(HttpStatusCode.NotFound));
                }
            }
            catch (Exception)
            {
                return(View(nameof(Index)));
            }
        }