示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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();
        }
示例#5
0
        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();
        }
示例#6
0
        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);
        }
示例#7
0
        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
        }
示例#8
0
        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();
            }
        }
示例#9
0
        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
        }
示例#10
0
        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"));
        }
示例#11
0
 public void AssignTaskToPerson(Task task)
 {
     _taskRepository.AssignTaskToPerson(task);
 }
示例#12
0
        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();
            }
        }
示例#13
0
 public void UpdateTask(Task existingTask)
 {
     _taskRepository.UpdateTask(existingTask);
 }
示例#14
0
 public void AddTaskToEvent(Task newTask)
 {
     _taskRepository.AddTaskToEvent(newTask);
 }
示例#15
0
        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");
        }
示例#16
0
 public void RemoveTaskFromPerson(Task task)
 {
     _taskRepository.RemoveTaskFromPerson(task);
 }
示例#17
0
        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);
        }
示例#18
0
 public void AssignVolunteerTaskToPerson(Task task, Person person)
 {
     _taskRepository.AssignVolunteerTaskToPerson(task, person);
 }
示例#19
0
        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;
        }