Exemplo n.º 1
0
        /// <summary>
        /// This function is loading daily task to listBox
        /// </summary>
        private void SetUpMyListBox()
        {
            myTasks = new List <ToDoTaskModel>();
            listBoxDailyTasks.Items.Clear();
            try
            {
                using (var dbContex = new ToDoAppDbContext())
                {
                    dayRepository      = new DayRepository(dbContex);
                    toDoTaskRepository = new ToDoTaskRepository(dbContex);
                    DayModel item = (DayModel)comboBoxDates.SelectedItem;

                    var day        = dayRepository.GetByDate(dayMapper.Map(item).Date);
                    var dailyTasks = toDoTaskRepository.GetByDate(day).AsParallel();
                    if (dailyTasks != null)
                    {
                        listBoxDailyTasks.DisplayMember = "Name";
                        foreach (var task in dailyTasks)
                        {
                            var taskModel = toDoTaskMapper.Map(task);
                            listBoxDailyTasks.Items.Add(taskModel);
                            myTasks.Add(taskModel);
                        }
                        listBoxDailyTasks.Update();
                        listBoxDailyTasks.SelectedItem = listBoxDailyTasks.Items[0];
                        FindNextTask.GetNextTask(myTasks, ref labelNextTaskValue);
                    }
                }
            }catch (Exception e)
            {
                MessageBox.Show("There are no tasks for the selected day");
            }
        }
Exemplo n.º 2
0
        public void CreateTask(TaskValidation taskValidation, DayRepository dayRepository, ToDoTaskRepository taskRepository, DayMapper dayMapper, TextBox textBoxName, TextBox textBoxDate, RichTextBox richTextBoxDescription, int statusValue, int priorityValue)
        {
            bool isCorrect = taskValidation.isInputOk(textBoxName.Text, richTextBoxDescription.Text, textBoxDate.Text);

            if (isCorrect)
            {
                using (var dbContex = new ToDoAppDbContext())
                {
                    dayRepository  = new DayRepository(dbContex);
                    taskRepository = new ToDoTaskRepository(dbContex);
                    var myDay = dayRepository.GetByDate(DateTime.Parse(textBoxDate.Text));
                    if (myDay == null)
                    {
                        dayMapper = new DayMapper();
                        var tempDay = new DayModel();
                        tempDay.Date = DateTime.Parse(textBoxDate.Text);
                        dayRepository.Update(dayMapper.Map(tempDay));
                    }
                    myDay = dayRepository.GetByDate(DateTime.Parse(textBoxDate.Text));
                    taskRepository.Update(new Database.Entities.TaskToDo
                    {
                        Name        = textBoxName.Text,
                        Description = richTextBoxDescription.Text,
                        DayId       = myDay.DayId,
                        Status      = statusValue,
                        Priority    = priorityValue
                    });
                }
                MessageBox.Show("The database was successfully modified");
            }
        }
Exemplo n.º 3
0
 public EuroleagueInformationLoader(
     DataBaseTools dataBaseTools,
     TeamRepository teamRepository,
     DayRepository dayRepository)
 {
     _dataBaseTools  = dataBaseTools;
     _teamRepository = teamRepository;
     _dayRepository  = dayRepository;
 }
Exemplo n.º 4
0
 /// <summary>
 /// This function loads all data into the form when editing data.
 /// </summary>
 private void SetUpValuesInForm()
 {
     SetUpTaskDetails.SetUpTextValuesInForm(taskModel, ref textBoxName, ref fkDay, ref richTextBoxDescription);
     using (var dbContex = new ToDoAppDbContext())
     {
         dayRepository = new DayRepository(dbContex);
         var myDay = dayRepository.GetById(fkDay);
         var date  = myDay.Date;
         dateTimePicker1.Value = date;
     }
     LoadRadioButtonValue();
 }
Exemplo n.º 5
0
        public UserController(UserContext userContext, CapstoneContext capstoneContext, DayContext dayContext, TaskContext taskContext, IConfiguration configuration)
        {
            _userContext     = userContext;
            _capstoneContext = capstoneContext;
            _dayContext      = dayContext;
            _taskContext     = taskContext;

            _configuration = configuration;

            userRepository     = new UserRepository(_userContext, _capstoneContext, _dayContext, _taskContext);
            capstoneRepository = new CapstoneRepository(_capstoneContext, _dayContext, _taskContext);
            dayRepository      = new DayRepository(_dayContext, _taskContext);
            taskRepository     = new TaskRepository(_taskContext);
        }
Exemplo n.º 6
0
 public void DeleteSelectedItem(DayRepository dayRepository, ToDoTaskRepository toDoTaskRepository, ListBox listBoxDailyTasks, ToDoTaskMapper toDoTaskMapper)
 {
     using (var dbContex = new ToDoAppDbContext())
     {
         dayRepository      = new DayRepository(dbContex);
         toDoTaskRepository = new ToDoTaskRepository(dbContex);
         var itemToDelete = toDoTaskRepository.GetByName(toDoTaskMapper.Map((ToDoTaskModel)listBoxDailyTasks.SelectedItem).Name);
         if (itemToDelete != null)
         {
             dbContex.DailyTasks.Remove(itemToDelete);
             dbContex.SaveChanges();
             MessageBox.Show("Task was deleted.");
         }
         else
         {
             MessageBox.Show("There is no task to delete.");
         }
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// This function is loading date into comboBix and order them
 /// </summary>
 private void LoadDataToMyComboBox()
 {
     comboBoxDates.Items.Clear();
     using (var dbContex = new ToDoAppDbContext())
     {
         dayRepository = new DayRepository(dbContex);
         var myDayList = dayRepository.GetAll().AsParallel();
         comboBoxDates.DisplayMember = "Date";
         if (myDayList != null)
         {
             myDayList.OrderBy(d => d.Date).AsParallel();
             foreach (var day in myDayList)
             {
                 var dayModel = dayMapper.Map(day);
                 comboBoxDates.Items.Add(dayModel);
             }
             comboBoxDates.SelectedIndex = comboBoxDates.Items.Count - 1;
         }
         else
         {
             MessageBox.Show("No data.");
         }
     }
 }
Exemplo n.º 8
0
 private void InitializeRepositories()
 {
     _dayRepository         = new DayRepository();
     _gymExerciseRepository = new GymExerciseRepository();
 }