Esempio n. 1
0
        public string CreateAccount(string body)
        {
            if (body == null)
            {
                return(Json.Serialize(new Packet <string>(0, "", "failed")));
            }

            Account requestBody = Json.Deserialize <Account>(body);
            int     result      = GetAccount(requestBody);

            if (result == ERROR_ACCOUNT_UNKNOWN)
            {
                string  id      = IDGenerator.GenerateUniqueId();
                Account account = new Account(requestBody.email, requestBody.password, id);

                accounts.Add(account);
                SaveAccounts();
                return(Json.Serialize(new Packet <string>(0, "", "success")));
            }

            return(Json.Serialize(new Packet <string>(0, "", "failed")));
        }