Exemplo n.º 1
0
 public HttpResponseMessage PostAccount(AccountModel json)
 {
     //var newAccount = AccountModel.CreateAccount(username, password, email);
     json.ID = IdentificationNumber.NewID();
     json.EntriesOwned = new List<IdentificationNumber>();
     json.EventsOwned = new List<IdentificationNumber>();
     json.CommentEntries = new List<IdentificationNumber>();
     SQLCommand.ExecuteQuery("INSERT INTO dbo.Users VALUES ('" + json.ID.ID + "','" + json.Username + "','" + json.Password + "','" + json.Email + "')");
     SQLCommand.ExecuteQuerySaveObject<AccountModel>("a", json);
     return new HttpResponseMessage(HttpStatusCode.Accepted);
 }
Exemplo n.º 2
0
 public HttpResponseMessage DeleteAccount(AccountModel model)
 {
     try
     {
         SQLCommand.ExecuteQueryRemoveAccount(model.ID.ID, model.Username, model.Password, model.Email);
         return new HttpResponseMessage(HttpStatusCode.OK);
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.StackTrace);
         return new HttpResponseMessage(HttpStatusCode.NotFound);
     }
 }
Exemplo n.º 3
0
        public static AccountModel CreateAccount(string username, string password, string email)
        {
            var am = new AccountModel()
            {
                Username = username,
                Password = password,
                Email = email,
                ID = IdentificationNumber.NewID(),
                EventsOwned = new List<IdentificationNumber>(),
                EntriesOwned = new List<IdentificationNumber>(),
                CommentEntries = new List<IdentificationNumber>()
            };
            am.EventsOwned.Add(IdentificationNumber.blankID());
            am.EntriesOwned.Add(IdentificationNumber.blankID());
            am.CommentEntries.Add(IdentificationNumber.blankID());

            return am;
        }