Exemplo n.º 1
0
        public bool UpdateUserById(int userId, SQLiteUser update, SQLiteConnecter connecter)
        {
            string updateCommand = string.Format("UPDATE User set Username='******', Password='******', Age='{2}', Gender='{3}' where id='{5}'",
                                                 update.Username, update.Password, update.Age, update.Gender, userId);

            return(ExecuteCommand(updateCommand, connecter.connection));
        }
Exemplo n.º 2
0
        public RegistrationPage(UserViewModel viewModel, string mode = "")
        {
            _mode          = mode;
            Globals.myAdID = "ca-app-pub-6838059012127071/4882317165";

            var sqliteUser  = new SQLiteUser(DependencyService.Get <ISQLiteDb>());
            var pageService = new PageService();

            Title    = mode == "setting" ? "User Setting" : "New User";
            RegModel = new RegistrationViewModel(viewModel ?? new UserViewModel(), sqliteUser, pageService, mode);
            InitializeComponent();
        }
Exemplo n.º 3
0
        public Result Login(string username, string password, SQLiteConnecter connecter)
        {
            DataSet           data    = new DataSet();
            SQLiteDataAdapter adapter = new SQLiteDataAdapter(
                string.Format("select id, Username, Password, Age, Gender from User where Username='******' AND Password='******'", username, password),
                connecter.connection);

            adapter.Fill(data);
            DataRow    entity = data.Tables[0].Rows[0];
            SQLiteUser user   = Utilities.ToObject <SQLiteUser>(entity);

            return(new Result
            {
                status = Status.OK,
                data = user
            });
        }
Exemplo n.º 4
0
 public ObjectResult CreateNewUser([FromBody] SQLiteUser user)
 {
     try
     {
         Result result = userSQLiteService.InsertUser(user, APIConnecter.SQLite);
         if (result.status == Status.Created)
         {
             return(Ok(Responder.Success(result.data)));
         }
         else
         {
             return(StatusCode(result.status, Responder.Fail(result.data)));
         }
     }
     catch (Exception error)
     {
         return(BadRequest(Responder.Fail(error.Message)));
     }
 }
Exemplo n.º 5
0
        public Result InsertUser(SQLiteUser user, SQLiteConnecter connecter)
        {
            string insertCommand = string.Format("INSERT INTO User(Username,Password,Age,Gender) VALUES('{0}', '{1}', '{2}', '{3}')",
                                                 user.Username, user.Password, user.Age, user.Gender);

            if (ExecuteCommand(insertCommand, connecter.connection))
            {
                string getIdCoommand = "SELECT last_insert_rowid()";
                int    _id           = Convert.ToInt32(ExecuteScalar(getIdCoommand, connecter.connection));
                return(new Result
                {
                    status = Status.Created,
                    data = _id
                });
            }
            else
            {
                return new Result
                       {
                           status = Status.BadRequest,
                           data   = Messages.BadRequest
                       }
            };
        }
 public bool AddUserDetails(UserDetails userDetails)
 {
     return(SQLiteUser.AddUserDetails(userDetails));
 }