Esempio 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)));
            }
        }
Esempio n. 2
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)));
            }
        }