Пример #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;
        }