예제 #1
0
 public void AddAccount(Account newAccount)
 {
     if (accounts.Select(x => x).Any(x => x.Username == newAccount.Username))
         throw new Exception();
     newAccount.TableID = tableID++;
     accounts.Add(newAccount);
 }
예제 #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="email"></param>
        /// <returns>Succeded boolean</returns>
        public bool TryCreateAccount(string name, string username, string password, string email)
        {
            //Is input parameters valid inputs? "" and null not allowed
            if (String.IsNullOrEmpty(name) || String.IsNullOrEmpty(username) || String.IsNullOrEmpty(password) || String.IsNullOrEmpty(email))
                return false;
            //Validate that we are online and that the username and email doesn't exist amoung allready existing accounts.
            if (!season.OnlineContext.isOnline())
                return false;
            if (season.OnlineContext.GetAccount(username) != null)
                return false;
            if (season.OnlineContext.GetAccount(email, true) != null)
                return false;

            //Is the value of email a valid e-mail format?
            //Regex validation snippet from http://msdn.microsoft.com/en-us/library/01escwtf%28v=vs.110%29.aspx.
            if (!Regex.IsMatch(email,
             @"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
             @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$"))
                return false;

            //Try creating the account, hitting the catch here could mean a connection issue or that
            //the synchronizing server rejected the AddAccount action. Only methods inside AccountLogic except
            //for TryLogin enforces for the OnlineContext to be in isOnline state.
            IAccount account = new Account(name, username, email, false);
            try
            {
                season.OnlineContext.AddAccount(account);
            }
            catch
            {
                return false;
            }
            return true;
        }
예제 #3
0
 public EventComposite(string title, string description, Account ownedByAccount,IAccount[] sharedWithAccount)
 {
     SharedWithAccounts = sharedWithAccount;
     eventComponents = new EventComponent[0];
     OwnedByAccount = ownedByAccount;
     Description = description;
     Title = title;
 }
예제 #4
0
파일: EventLeaf.cs 프로젝트: Rabka/BDSA2014
 public EventLeaf(INotification[] notifications, Account[] sharedWithAccounts, Account ownedByAccount, string description, DateTime dateTo, DateTime dateFrom)
 {
     DateFrom = dateFrom;
     DateTo = dateTo;
     Description = description;
     OwnedByAccount = ownedByAccount;
     SharedWithAccounts = sharedWithAccounts;
     Notifications = notifications;
 }
예제 #5
0
파일: EventLeaf.cs 프로젝트: Rabka/BDSA2014
 public EventLeaf(string title, string description, DateTime dateFrom, DateTime dateTo, Account ownedByAccount, Account[] sharedWithAccounts, INotification[] notifications)
 {
     Title = title;
     DateFrom = dateFrom;
     DateTo = dateTo;
     Description = description;
     OwnedByAccount = ownedByAccount;
     SharedWithAccounts = sharedWithAccounts;
     Notifications = notifications;
 }
예제 #6
0
        public void SetUp()
        {
            seasonStub = new SeasonStub();
            accountLogic = new AccountLogic(seasonStub);

            Maccount = new Account("Maccount", "u", "*****@*****.**", true);
            seasonStub.CurrentAccount = Maccount;
            accountLogic.TryCreateAccount("Maccount", "Mpassword", "*****@*****.**");
            accountLogic = new AccountLogic(seasonStub);
        }
예제 #7
0
 public void RemoveAccount(Account account)
 {
     accounts.Remove(accounts.Select(x => x).First(x => x.TableID == account.TableID));
 }
예제 #8
0
 public void UpdateAccount(Account account)
 {
 }
예제 #9
0
 /// <summary>
 /// Removes a specified account.
 /// </summary>
 /// <param name="account"></param>
 /// <returns>return true if success</returns>
 public bool TryRemoveAccount(Account account)
 {
     throw new NotImplementedException();
 }
예제 #10
0
 /// <summary>
 /// Joins multiple components together to a composite.
 /// </summary>
 /// <returns>EventsComposite</returns>
 public EventComposite JoinComponentsToNewComposite(string title, string description, Account ownedByAccount, params EventComponent[] components)
 {
     throw new NotImplementedException();
 }
예제 #11
0
 public EventComposite(string title, string description, Account ownedByAccount)
 {
     OwnedByAccount = ownedByAccount;
     Description = description;
     Title = title;
 }
예제 #12
0
 public void SetUp()
 {
     seasonStub = new SeasonStub();
     accountLogic = new AccountLogic(seasonStub);
     Maccount = new Account("SeaasonStub person", "u", "p", true);
     seasonStub.CurrentAccount = Maccount;
 }
예제 #13
0
 public void SetUp()
 {
     seasonStub = new SeasonStub();
     accountLogic = new AccountLogic(seasonStub);
     //This user is precreated by default in SeasonStub.
     Maccount = new Account("SeaasonStub person", "u", "p", true);
     //Setting CurrentAccount to Maccount enforces that we are logged in as Maccount.
     seasonStub.CurrentAccount = Maccount;
 }
예제 #14
0
파일: RDBMS.cs 프로젝트: Rabka/BDSA2014
 public void AddAccount(Account newAccount)
 {
     throw new NotImplementedException();
 }
예제 #15
0
        public void SetUp()
        {
            kim = new Account("Kim", "Kim", "[email protected]", false);
            ole = new Account("Ole", "Ole", "[email protected]", false);
            pia = new Account("Pia", "Pia", "[email protected]", false);

            EventComponent[] events = new EventComponent[5];
            events[0] = new EventLeaf("Event1", "A description", DateTime.Parse("11-11-11"), DateTime.Parse("11-11-12"), kim, new Account[] { }, new INotification[] { });
            events[1] = new EventLeaf("", "", DateTime.Parse("11-11-10"), DateTime.Parse("11-11-11"), ole, new[] { kim}, new INotification[] { new Notification(DateTime.Parse("11-11-9"), false)});
            events[2] = new EventLeaf("Event3", "A description", DateTime.Parse("11-11-11"), DateTime.Parse("11-11-12"), kim, new[] { kim, ole}, new INotification[] { });
            events[3] = new EventLeaf("Event4", "A description", DateTime.Parse("11-11-11"), DateTime.Parse("11-11-12"), ole, new[] { kim, ole, pia }, new INotification[] { });
            events[4] = new EventLeaf("Event5", "A description", DateTime.Parse("11-11-9"), DateTime.Parse("11-11-13"), pia, new Account[] { }, new INotification[] { new Notification(DateTime.Parse("11-11-9"), false)});

            Event1 = events[0];
            Event2 = events[1];

            EventComposite e1 = new EventComposite("Compo1", "A grup description",kim, new IAccount[0]);
            e1.eventComponents = new EventComponent[] {events[0], events[1]};
            Event3 = e1;

            EventComposite e2 = new EventComposite("Compo2", "A grup description", ole, new IAccount[0]);
            e2.eventComponents = new EventComponent[] {};
            Event4 = e2;

            EventComposite e3 = new EventComposite("Compo3", "A grup description", kim, new IAccount[0]);
            e3.eventComponents = new EventComponent[] { events[0], events[1], events[2], events[3], events[4] };
            Event5 = e3;

            EventComposite e4 = new EventComposite("Compo4", "A grup description2", pia, new IAccount[0]);
            e4.eventComponents = new EventComponent[] { e1, e3 };
            Event6 = e4;
        }
예제 #16
0
파일: RDBMS.cs 프로젝트: Rabka/BDSA2014
 public void UpdateAccount(Account account)
 {
     throw new NotImplementedException();
 }
예제 #17
0
 /// <summary>
 /// Removes a specified account.
 /// </summary>
 /// <param name="account"></param>
 public static void RemoveAccount(Season season, Account account)
 {
     throw new NotImplementedException();
 }