Esempio n. 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);
        }
Esempio n. 2
0
        public void ChangePassword(int id, string oldPasswordHash, string newPasswordHash)
        {
            var p = _dbContext.People.Find(id);

            if (String.IsNullOrEmpty(p.PasswordHash))
            {
                throw new ArgumentNullException(oldPasswordHash);
            }
            if (p.PasswordHash == oldPasswordHash)
            {
                p.PasswordHash = newPasswordHash;
            }
            _dbContext.SaveChanges();

            IMailService svc = new SmtpMailService();
            svc.SendPasswordChangeMail(p.Email);
        }
Esempio n. 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);
        }
Esempio n. 4
0
        public void ResetPassword(string emailAddress, string temporaryPassword, string temporaryPasswordHash)
        {
            if (String.IsNullOrEmpty(emailAddress))
            {
                throw new ArgumentNullException(emailAddress, "email address must be provided.");
            }

            var bcAttendee =
                _dbContext.People.SingleOrDefault(p => p.Email == emailAddress);

            if (bcAttendee == null)
            {
                throw new ArgumentOutOfRangeException(emailAddress, "attendee was not found.");
            }

            if (!String.IsNullOrEmpty(temporaryPasswordHash))
            {
                bcAttendee.PasswordHash = temporaryPasswordHash;
            }
            _dbContext.SaveChanges();

            IMailService svc = new SmtpMailService();
            svc.SendPasswordResetMail(emailAddress, temporaryPassword);
        }