public async Task <IActionResult> Edit(int id, [Bind("Id,TDate")] TaskDate taskDate)
        {
            if (id != taskDate.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(taskDate);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TaskDateExists(taskDate.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(taskDate));
        }
        //public static readonly IGenericDal<TaskDate> genericDal;

        public static async Task SeedData(ITaskDateDal _genericDal)
        {
            var veri = _genericDal.FindAsync("Günlük");

            if (veri.Count == 0)
            {
                var gunluk = new TaskDate {
                    Name = "Günlük"
                };
                await _genericDal.AddAsync(gunluk);
            }

            var hafta = _genericDal.FindAsync("Haftalık");

            if (hafta.Count == 0)
            {
                var haftalık = new TaskDate {
                    Name = "Haftalık"
                };
                await _genericDal.AddAsync(haftalık);
            }

            var ay = _genericDal.FindAsync("Aylık");

            if (ay.Count == 0)
            {
                var aylik = new TaskDate {
                    Name = "Aylık"
                };
                await _genericDal.AddAsync(aylik);
            }
        }
Example #3
0
        //public async Task<IActionResult> Set_Taskdate_Ajax([FromBody] TaskDateRequestModel t)
        public string Set_Taskdate_Ajax([FromBody] TaskDateRequestModel t)
        {
            if (t != null)
            {
                UserAccount u = GetUser();

                int task_id = t.task_id;

                // Check that the task belongs to user
                var task = _context.DailyTasks.Include(
                    t => t.TableTask
                    ).First(
                    t => t.Id == task_id);
                if (task.TableTask.UserAccountId != u.Id)
                {
                    return("");
                }

                var d  = new DateTime(t.year, t.month, t.day);
                var td = _context.TaskDates.
                         FirstOrDefault(dt => dt.TDate == d);

                if (td == null)
                {
                    td = new TaskDate {
                        TDate = d
                    };
                    _context.Add(td);
                    _context.SaveChanges();
                }

                var dt_td = _context.DailyTask_TaskDates.
                            FirstOrDefault(dt => dt.DailyTaskId == task_id &&
                                           dt.TaskDateId == td.Id
                                           );

                if (dt_td == null)
                {
                    dt_td = new DailyTask_TaskDate
                    {
                        DailyTaskId = task_id,
                        //DailyTask = task,
                        TaskDateId = td.Id,
                        //TaskDate = td
                    };
                    _context.Add(dt_td);
                    _context.SaveChanges();
                }
                else    // Remove
                {
                    _context.DailyTask_TaskDates.Remove(dt_td);
                    _context.SaveChanges();
                }

                return(t.task_id.ToString());
            }
            return("");
        }
Example #4
0
        // Gets Dictionary of the tasks asychronously only
        public string Get_Tasks_Json(int year, int month)
        {
            UserAccount u = GetUser();

            if (u != null)
            {
                var options = new JsonSerializerOptions
                {
                    //PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
                    WriteIndented = true
                };
                var tasks = GetTasks();

                if (String.IsNullOrEmpty(year.ToString()) ||
                    String.IsNullOrEmpty(month.ToString()))
                {
                    DateTime date = DateTime.Now;
                    year  = date.Year;
                    month = date.Month;
                }

                var firstDay = new DateTime(year, month, 1);
                var lastDay  = firstDay.AddMonths(1).AddDays(-1);

                Dictionary <string, Dictionary <string, string> > tasks_dictionary =
                    new Dictionary <string, Dictionary <string, string> >();

                int task_id;
                Dictionary <string, string> task_dict;
                foreach (DailyTask t in tasks)
                {
                    task_id   = t.Id;
                    task_dict = new Dictionary <string, string>();
                    _context.DailyTask_TaskDates.Where(
                        dt_t => dt_t.DailyTaskId == task_id &&
                        dt_t.TaskDate.TDate >= firstDay &&
                        dt_t.TaskDate.TDate <= lastDay).Include(td_td => td_td.TaskDate).Load();
                    string task_dates = "";
                    if (t.DailyTask_TaskDates != null)
                    {
                        foreach (DailyTask_TaskDate dt_t in t.DailyTask_TaskDates)
                        {
                            _context.TaskDates.Where(td => dt_t.TaskDateId == td.Id).Load();
                            TaskDate td = dt_t.TaskDate;
                            task_dates += td.TDate.ToString("yyyy-MM-dd") + "_";
                        }
                        task_dates.TrimEnd('_');
                    }

                    task_dict.Add("name", t.name);
                    task_dict.Add("date_string", task_dates);
                    tasks_dictionary.Add(t.Id.ToString(), task_dict);
                }
                var tasks_json = JsonSerializer.Serialize(tasks_dictionary, tasks_dictionary.GetType(), options);
                return(tasks_json);
            }
            return("{}");
        }
        public async Task <IActionResult> Create([Bind("Id,TDate")] TaskDate taskDate)
        {
            if (ModelState.IsValid)
            {
                _context.Add(taskDate);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(taskDate));
        }
Example #6
0
        public void CreateTaskDateAndMarkAsDone()
        {
            TaskDate taskDate = new TaskDate();

            taskDate.CreateTask("26/14/2019", "CreateTaskDate");
            taskDate.SetTaskStatus(true, false, false);
            bool result = false;

            if (taskDate.TaskStatus.done == true)
            {
                result = true;
            }
            Assert.True(result, "The task hasnt been marked as done");
        }
Example #7
0
        public void CreateTaskDate()
        {
            TaskDate taskDate = new TaskDate();

            taskDate.CreateTask("26/14/2019", "CreateTaskDate");
            bool result = false;

            if (taskDate.GetTask().Contains("CreateTaskDate") &&
                taskDate.GetTaskTodoDate().Contains("26/14/2019"))
            {
                result = true;
            }
            Assert.True(result, "result dont contain string");
        }
Example #8
0
        public void CreateTaskDateAndMarkAsDoneAndArchive()
        {
            TaskDate taskDate = new TaskDate();

            taskDate.CreateTask("26/14/2019", "CreateTaskDate");
            taskDate.SetTaskStatus(true, false, false);
            Program.taskDate.Add(taskDate);
            int  result         = Program.ArchiveAllDoneTask();
            bool resultArchived = false;

            if (result == 0)
            {
                resultArchived = true;
            }
            Assert.True(resultArchived, "No task has been archived");
        }
Example #9
0
        public async Task <List <TaskDate> > GetAsync()
        {
            var veri = await _generictaskdate.GetAllAsync();

            List <TaskDate> a = new List <TaskDate>();

            foreach (var item in veri)
            {
                TaskDate b = new TaskDate();
                b.Id   = item.Id;
                b.Name = item.Name;

                a.Add(b);
            }

            return(a);
        }
        public CalendarWindow(MainWindow mainWindow)
        {
            this.mainWindow = mainWindow;
            InitializeComponent();
            HashSet <DateTime> dateTimes = new HashSet <DateTime>();

            dateTimes.Add(new DateTime(2019, 12, 1));

            mycalendar.BlackoutDates.Add(
                new CalendarDateRange(new DateTime(2019, 11, 2), new DateTime(2019, 11, 4)));

            TaskDate taskDate = new TaskDate(new DateTime(2019, 12, 2));

            this.DataContext = taskDate;
            //mycalendar.SelectedDates.Add(new DateTime(2019, 12, 2));
            //mycalendar.SelectedDates.Add(new DateTime(2019, 12, 5));

            //mycalendar.SelectedDates.Add(new DateTime(2019, 12, 6));
            //mycalendar.SelectedDates.Add(new DateTime(2019, 12, 7));
        }