예제 #1
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);
        }
예제 #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 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);
        }
예제 #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");
                }

                //OCC.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 AssignVolunteerTaskToPerson(Task task, Person person)
        {
            var e = _dbContext.Tasks.Find(task.Id);

            if (e == null)
            {
                throw new ArgumentException("Task not found");
            }

            //OCC.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
        }
예제 #9
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();
            }
        }
예제 #10
0
        private static void MapAllCurrentEventTasks(ICollection <Task> tasks, IEnumerable <Data.Task> currentEventTasks)
        {
            foreach (var currentEventTask in currentEventTasks)
            {
                var eventTask = new Task
                {
                    Id          = currentEventTask.ID,
                    EventID     = currentEventTask.Event_ID,
                    Capacity    = currentEventTask.Capacity,
                    Description = currentEventTask.Description,
                    StartTime   = currentEventTask.StartTime,
                    EndTime     = currentEventTask.EndTime
                };

                foreach (var personTask in currentEventTask.PersonTasks)
                {
                    eventTask.Assignees.Add(personTask.Person.Map());
                }
                tasks.Add(eventTask);
            }
        }
예제 #11
0
        private static void MapAllCurrentEventTasks(ICollection<Task> tasks, IEnumerable<Data.Task> currentEventTasks)
        {
            foreach (var currentEventTask in currentEventTasks)
            {
                var eventTask = new Task
                {
                    Id = currentEventTask.ID,
                    EventID = currentEventTask.Event_ID,
                    Capacity = currentEventTask.Capacity,
                    Description = currentEventTask.Description,
                    StartTime = currentEventTask.StartTime,
                    EndTime = currentEventTask.EndTime
                };

                foreach (var personTask in currentEventTask.PersonTasks)
                {
                    eventTask.Assignees.Add(personTask.Person.Map());
                }
                tasks.Add(eventTask);
            }
        }
예제 #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 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);
        }
예제 #14
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;
        }