public void AssignTaskToPerson(Task task) { if (task == null || task.Assignees.Count == 0) { return; } if (task.Id == 0 || task.Assignees[0].ID == 0) { return; } var personId = task.Assignees[0].ID; Data.Task assignedTask; Data.Person assignedPerson; var t = new Data.PersonTask { Person_ID = task.Assignees[0].ID, Task_ID = task.Id }; _dbContext.PersonTasks.Add(t); _dbContext.SaveChanges(); assignedTask = _dbContext.Tasks.FirstOrDefault(at => at.ID == task.Id); assignedPerson = _dbContext.People.FirstOrDefault(ap => ap.ID == personId); IMailService mailService = new SmtpMailService(); mailService.SendTaskRegistrationMail(assignedTask, assignedPerson.Email); }
public void AssignTaskToPerson(Task task) { if (task == null || task.Assignees.Count == 0) { return; } if (task.Id == 0 || task.Assignees[0].ID == 0) { return; } var personId = task.Assignees[0].ID; Data.Task assignedTask; Data.Person assignedPerson; var t = new Data.PersonTask {Person_ID = task.Assignees[0].ID, Task_ID = task.Id}; _dbContext.PersonTasks.Add(t); _dbContext.SaveChanges(); assignedTask = _dbContext.Tasks.FirstOrDefault(at => at.ID == task.Id); assignedPerson = _dbContext.People.FirstOrDefault(ap => ap.ID == personId); IMailService mailService = new SmtpMailService(); mailService.SendTaskRegistrationMail(assignedTask, assignedPerson.Email); }
public void RemoveTaskFromPerson(Task task) { if (task == null || task.Assignees.Count == 0) { return; } //enter email address here const string boardEmailAddress = "*****@*****.**"; int personId = task.Assignees[0].ID; int taskId = task.Id; var pt = _dbContext.PersonTasks.FirstOrDefault(x => x.Person_ID == personId && x.Task_ID == taskId); if (pt == null) { return; } _dbContext.PersonTasks.Remove(pt); _dbContext.SaveChanges(); var unAssignedTask = _dbContext.Tasks.FirstOrDefault(t => t.ID == taskId); IMailService mailService = new SmtpMailService(); mailService.SendTaskRevokeMail(unAssignedTask, boardEmailAddress); }
public void AddTaskToEvent(Task newTask) { if (newTask == null) { throw new ArgumentNullException("newTask", "task cannot be null"); } var task = newTask.Map(); _dbContext.Tasks.Add(task); _dbContext.SaveChanges(); }
public Task GetTaskById(int taskId) { var dcTask = new Task(); var task = _dbContext.Tasks .Include("Event") .Where(s => s.ID == taskId) .SingleOrDefault(); if (task != null) { dcTask = task.Map(); } return(dcTask); }
public void AssignVolunteerTaskToPerson(Task task, Person person) { var e = _dbContext.Tasks.Find(task.Id); if (e == null) { throw new ArgumentException("Task not found"); } //CC.Data.Task bcTask = e.Map(); //task.Volunteers.Add() //List<Track> result = new List<Track>(); //foreach (var track in e.Tracks) // result.Add(track.Map()); //result }
public void UpdateTask(Task existingTask) { if (existingTask == null) { throw new ArgumentNullException("existingTask", "task cannot be null"); } var task = _dbContext.Tasks.FirstOrDefault(t => t.ID == existingTask.Id); if (task != null) { task.StartTime = existingTask.StartTime; task.EndTime = existingTask.EndTime; task.Description = existingTask.Description; task.Capacity = existingTask.Capacity; task.Event_ID = existingTask.EventID; _dbContext.SaveChanges(); } }
public ActionResult Volunteers(int?id, string btnSubmit, FormCollection collection) { int taskId; var taskIdPassedInFromFormPost = Request[CONST_TASK_PARAMETER_ID]; Int32.TryParse(taskIdPassedInFromFormPost, out taskId); if (taskId == 0) { throw new ApplicationException("taskId is invalid."); } var currentUser = CurrentUser; if (currentUser != null) { var task = new Services.Task { Id = taskId }; if (task.Assignees == null || task.Assignees.Count == 0) { task.Assignees = new Services.Person[1]; } task.Assignees[0] = new Services.Person { ID = currentUser.ID }; switch (btnSubmit) { case "add": this.service.AssignTaskToPerson(task); break; case "remove": this.service.RemoveTaskFromPerson(task); break; } // TODO Tell the user it was successful. // https://github.com/akquinet/jquery-toastmessage-plugin/wiki } return(RedirectToAction("Volunteers", "Home")); }
public void AssignTaskToPerson(Task task) { _taskRepository.AssignTaskToPerson(task); }
public void UpdateTask(Task existingTask) { _taskRepository.UpdateTask(existingTask); }
public void AddTaskToEvent(Task newTask) { _taskRepository.AddTaskToEvent(newTask); }
public ActionResult Volunteers(int? id, string btnSubmit, FormCollection collection) { int taskId; var taskIdPassedInFromFormPost = Request[CONST_TASK_PARAMETER_ID]; Int32.TryParse(taskIdPassedInFromFormPost, out taskId); if (taskId == 0) { throw new ApplicationException("taskId is invalid."); } var currentUser = CurrentUser; if (currentUser != null) { var task = new Services.Task { Id = taskId }; if (task.Assignees == null) { task.Assignees = new Services.Person[1]; } task.Assignees[0] = new Services.Person { ID = currentUser.ID }; switch (btnSubmit) { case "add": this.service.AssignTaskToPerson(task); break; case "remove": this.service.RemoveTaskFromPerson(task); break; } // TODO Tell the user it was successful. // https://github.com/akquinet/jquery-toastmessage-plugin/wiki } return RedirectToAction("Volunteers", "Home"); }
public void RemoveTaskFromPerson(Task task) { _taskRepository.RemoveTaskFromPerson(task); }
public void RemoveTaskFromPerson(Task task) { if (task == null || task.Assignees.Count == 0) { return; } //enter email address here const string boardEmailAddress = ""; int personId = task.Assignees[0].ID; int taskId = task.Id; var pt = _dbContext.PersonTasks.FirstOrDefault(x => x.Person_ID == personId && x.Task_ID == taskId); if (pt == null) { return; } _dbContext.PersonTasks.Remove(pt); _dbContext.SaveChanges(); var unAssignedTask = _dbContext.Tasks.FirstOrDefault(t => t.ID == taskId); IMailService mailService = new SmtpMailService(); mailService.SendTaskRevokeMail(unAssignedTask, boardEmailAddress); }
public void AssignVolunteerTaskToPerson(Task task, Person person) { _taskRepository.AssignVolunteerTaskToPerson(task, person); }
public Task GetTaskById(int taskId) { var dcTask = new Task(); var task = _dbContext.Tasks .Include("Event") .Where(s => s.ID == taskId) .SingleOrDefault(); if (task != null) { dcTask = task.Map(); } return dcTask; }