public static async Task AddTestData(ToDoAppDbContext context) { if (context.ToDoItems.Any()) { return; } context.ToDoItems.Add(new ToDoItemEntity { Name = "Get Groceries", IsComplete = true }); context.ToDoItems.Add(new ToDoItemEntity { Name = "Walk Dogs", IsComplete = false }); context.ToDoItems.Add(new ToDoItemEntity { Name = "Study", IsComplete = false }); await context.SaveChangesAsync(); }
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"); } }
public IEnumerable <DtoToDoItem> GetAll() { using (var context = new ToDoAppDbContext(_configuration.GetConnectionString("ToDoApp"))) { return(context.ToDoList.ToList()); } }
/// <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"); } }
public void Update(DtoToDoItem entity) { using (var context = new ToDoAppDbContext(_configuration.GetConnectionString("ToDoApp"))) { context.ToDoList.Update(entity); context.SaveChanges(); } }
public void Delete(DtoUser entity) { using (var context = new ToDoAppDbContext(_configuration.GetConnectionString("ToDoApp"))) { context.Users.Remove(entity); context.SaveChanges(); } }
public List <TaskItem> GetByDates(DateTime?date) { using (ToDoAppDbContext context = _contextFactory.CreateContext()) { List <TaskItem> entities = context.Set <TaskItem>().Where(((e) => e.TaskDate == date)).ToList(); return(entities); } }
public Task <IEnumerable <T> > GetAll() { using (ToDoAppDbContext context = _contextFactory.CreateContext()) { IEnumerable <T> entities = context.Set <T>().ToList(); return((Task <IEnumerable <T> >)entities); } }
public async Task <TeamMember> Get(int id) { using (ToDoAppDbContext context = _contextFactory.CreateContext()) { TeamMember entity = context.Set <TeamMember>().FirstOrDefault((e) => e.Id == id); return(entity); } }
public async Task <IEnumerable <TeamMember> > GetAll() { using (ToDoAppDbContext context = _contextFactory.CreateContext()) { IEnumerable <TeamMember> entities = await context.Set <TeamMember>().ToListAsync(); return(entities); } }
public List <TaskItem> GetAllItems() { using (ToDoAppDbContext context = _contextFactory.CreateContext()) { List <TaskItem> entities = context.Set <TaskItem>().ToList(); return(entities); } }
public List <TeamMember> GetAllMembers() { using (ToDoAppDbContext context = _contextFactory.CreateContext()) { List <TeamMember> entities = context.Set <TeamMember>().ToList(); return(entities); } }
public async Task <TeamMember> Create(TeamMember entity) { using (ToDoAppDbContext context = _contextFactory.CreateContext()) { var createdEntity = context.Members.Add(entity); await context.SaveChangesAsync(); return(createdEntity); } }
public async Task <bool> Delete(int id) { using (ToDoAppDbContext context = _contextFactory.CreateContext()) { TeamMember entity = context.Set <TeamMember>().FirstOrDefault((e) => e.Id == id); context.Set <TeamMember>().Remove(entity); await context.SaveChangesAsync(); return(true); } }
/// <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(); }
public async Task <TeamMember> Update(int id, TeamMember entity) { using (ToDoAppDbContext context = _contextFactory.CreateContext()) { entity.Id = id; context.Set <TeamMember>().Add(entity); await context.SaveChangesAsync(); return(entity); } }
public Form1() { InitializeComponent(); BindMyButtonsToEvent(); dayMapper = new DayMapper(); toDoTaskMapper = new ToDoTaskMapper(); taskMapper = new ToDoTaskMapper(); deleteItem = new DeleteItem(); using (var dbContex = new ToDoAppDbContext()) { dbContex.Database.EnsureCreated(); } LoadDataToMyComboBox(); //SetUpMyListBox(); mainTimer.Start(); }
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."); } } }
/// <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."); } } }
public DayRepository(ToDoAppDbContext dbContext) : base(dbContext) { }
public ToDoTaskRepository(ToDoAppDbContext dbContext) : base(dbContext) { }
public DefaultToDoItemService(ToDoAppDbContext context, IConfigurationProvider configurationProvider) { _context = context; _mappingConfig = configurationProvider; }
public LoginController(ToDoAppDbContext context, IConfiguration Configuration) { _configuration = Configuration; }
public ToDoController(ToDoAppDbContext db) { _db = db; }
public ToDoTasksController(ToDoAppDbContext context) { _context = context; }
public BaseRepository(ToDoAppDbContext dbContext) { DbContext = dbContext; }