Ejemplo n.º 1
0
        public CreateAccountResult CreateAccount(Account account)
        {
            CreateAccountResult result = new CreateAccountResult();

            if (_repository.ExistsForEmail(account.Email)) {
                result.Status = CreateAccountStatus.DuplicateEmail;
                result.Message = String.Format("An account already exists for '{0}'.", account.Email);
                return result;
            }

            // Assign created date.
            account.Created = DateTime.UtcNow;

            // Assign Central Standard Time if no timezone provided.
            if (String.IsNullOrEmpty(account.TimeZoneID))
                account.TimeZoneID = "Central Standard Time";

            // Save the new account.
            _repository.Save(account);

            // Initialize inbox.
            TaskList inbox = new TaskList { Title = "Inbox", TaskListType = TaskListType.Inbox };
            _taskListService.CreateTaskList(inbox, account);
            account.Inbox = inbox;

            // Create sample task and add to inbox.
            Task task = new Task { Title = "Welcome to Hover Tasks!", Note = "Get started by adding tasks, organizing them with lists and areas, and categorizing them with tags." };
            account.Inbox.AddTask(task);
            _taskService.CreateTask(task, account);
            
            return result;
        }
Ejemplo n.º 2
0
        public CreateAccountResult CreateAccount(Account account)
        {
            CreateAccountResult result = new CreateAccountResult();

            // Check for existing account.
            if (_repository.ExistsForEmail(account.Email)) {
                result.Status = CreateAccountStatus.DuplicateEmail;
                result.Message = String.Format("An account already exists for '{0}'.", account.Email);
                return result;
            }

            // Assign created date.
            account.Created = DateTime.UtcNow;

            // Assign Central Standard Time if no timezone provided.
            if (String.IsNullOrEmpty(account.TimeZoneID))
                account.TimeZoneID = "Central Standard Time";

            // Assign default theme.
            account.CurrentTheme = Account.DefaultTheme;

            // Save the new account.
            _repository.Save(account);

            // Initialize inbox.
            TaskList inbox = new TaskList { Title = "Inbox", TaskListType = TaskListType.Inbox };
            _taskListService.CreateTaskList(inbox, account);
            account.Inbox = inbox;

            // Intialize with "getting started" area.
            InitializeGettingStarted(account);
            
            // Create mail message.
            MailMessage message = new MailMessage();
            message.To.Add(account.Email);
            message.Subject = "Welcome to Hover Tasks";
            message.Body = "Your Hover Tasks Beta account has been created. We are looking forward to your feedback. Thanks! --The Hover Team";

            // Send email.
            SmtpClient client = new SmtpClient();
            client.Send(message);
            
            return result;
        }