Exemplo n.º 1
0
        public bool Create(User user)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>
            {
                { "@email", user.Email }
            };

            MySqlDataReader dataReader = mySQLConnector.GetData("SELECT * FROM users WHERE email = @email", parameters);

            if (dataReader.HasRows != true)
            {
                Dictionary <string, string> newUser = new Dictionary <string, string>
                {
                    { "@firstname", user.Firstname },
                    { "@lastname", user.Lastname },
                    { "@password", user.Password },
                    { "@email", user.Email },
                    { "@picture", user.Picture }
                };

                bool response = mySQLConnector.Execute("INSERT INTO users (firstname, lastname, password, email, picture) VALUES (@firstname, @lastname, @password, @email, @picture)", newUser);
                if (response)
                {
                    mySQLConnector.CloseConnections(dataReader);

                    return(true);
                }
            }
            mySQLConnector.CloseConnections(dataReader);

            return(false);
        }
Exemplo n.º 2
0
        public bool Create(Task task)
        {
            Dictionary <string, string> newTask = new Dictionary <string, string>();

            newTask.Add("@parent_task_id", task.ParentTask?.Id.ToString());
            newTask.Add("@requires_task_id", task.RequiresTask?.Id.ToString());
            newTask.Add("@section_id", task.SectionID.ToString());
            newTask.Add("@user_id", task.AssignedUser?.Id.ToString());
            newTask.Add("@name", task.Name);
            newTask.Add("@description", task.Description);
            newTask.Add("@due_date", task.DueDate.ToString("yyyy/MM/dd HH:mm:ss"));
            newTask.Add("@estimated_time", task.EstimatedTime.ToString());
            newTask.Add("@priority", task.Priority.ToString());

            bool response = mySQLConnector.Execute("INSERT INTO tasks (parent_task_id, requires_task_id, section_id, user_id, name, description, due_date, estimated_time, priority) VALUES (@parent_task_id, @requires_task_id , @section_id, @user_id, @name, @description, @due_date, @estimated_time, @priority)", newTask);

            mySQLConnector.CloseConnections();

            if (response)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
 public Boolean Save()
 {
     if (isEditing)
     {
         Dictionary <string, object> param = new Dictionary <string, object>
         {
             { "@id", editingRace.Id }
         };
         mySQLConnector.Execute("DELETE FROM race_checkpoints WHERE race_id=@id", param);
         foreach (KeyValuePair <int, Checkpoint> kvp in editingRace.checkpoints)
         {
             param = new Dictionary <string, object>
             {
                 { "@id", editingRace.Id },
                 { "@checkpoint_number", kvp.Key },
                 { "@checkpoint_pos_x", kvp.Value.Position.X },
                 { "@checkpoint_pos_y", kvp.Value.Position.Y },
                 { "@checkpoint_pos_z", kvp.Value.Position.Z },
                 { "@checkpoint_size", kvp.Value.Size },
                 { "@checkpoint_type", kvp.Value.Type }
             };
             mySQLConnector.Execute("INSERT INTO race_checkpoints " +
                                    "(race_id, checkpoint_number, checkpoint_pos_x, checkpoint_pos_y, checkpoint_pos_z, checkpoint_size, checkpoint_type) VALUES" +
                                    "(@id, @checkpoint_number, @checkpoint_pos_x, @checkpoint_pos_y, @checkpoint_pos_z, @checkpoint_size, @checkpoint_type)", param);
         }
         param = new Dictionary <string, object>
         {
             { "@id", editingRace.Id }
         };
         mySQLConnector.Execute("DELETE FROM race_spawnpos WHERE race_id=@id", param);
         for (int i = 0; i < editingRace.startingSpawn.Length; i++)
         {
             param = new Dictionary <string, object>
             {
                 { "@id", editingRace.Id },
                 { "@spawn_index", i },
                 { "@spawn_pos_x", editingRace.startingSpawn[i].Position.X },
                 { "@spawn_pos_y", editingRace.startingSpawn[i].Position.Y },
                 { "@spawn_pos_z", editingRace.startingSpawn[i].Position.Z },
                 { "@spawn_rot", editingRace.startingSpawn[i].Rotation },
             };
             mySQLConnector.Execute("INSERT INTO race_spawnpos " +
                                    "(race_id, spawn_index, spawnpos_x, spawnpos_y, spawnpos_z, spawnpos_rot) VALUES " +
                                    "(@id, @spawn_index, @spawn_pos_x, @spawn_pos_y, @spawn_pos_z, @spawn_rot)", param);
         }
         return(mySQLConnector.RowsAffected > 0);
     }
     return(false);
 }
Exemplo n.º 4
0
        public bool Create(Section section)
        {
            var newSection = new Dictionary <string, string>();

            newSection.Add("@project_id", section.ProjectId.ToString());
            newSection.Add("@name", section.Name);
            newSection.Add("@due_date", section.DueDate.ToString());

            bool response = mySQLConnector.Execute("INSERT INTO sections (project_id, name, due_date) VALUES (@project_id, @name, @due_date)", newSection);

            mySQLConnector.CloseConnections();

            if (response)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 5
0
        public bool Create(WorkLog workLog)
        {
            Dictionary <string, string> newWorkLog = new Dictionary <string, string>();

            newWorkLog.Add("@user_id", workLog.AssignedUser?.Id.ToString());
            newWorkLog.Add("@task_id", workLog.TaskID.ToString());
            newWorkLog.Add("@work", workLog.Work.ToString());
            newWorkLog.Add("@created_at", workLog.CreatedAt.ToString("yyyy/MM/dd HH:mm:ss"));


            bool response = mySQLConnector.Execute("INSERT INTO work_log (user_id, task_id, work, created_at) VALUES (@user_id, @task_id , @work, @created_at)", newWorkLog);

            mySQLConnector.CloseConnections();

            if (response)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 6
0
        public bool Create(Project project)
        {
            Dictionary <string, string> newProject = new Dictionary <string, string>
            {
                { "@parent_project_id", project.ParentProjectID.ToString() },
                { "@user_id", project.ProjectOwnerID.ToString() },
                { "@name", project.Name },
                { "@description", project.Description },
                { "@due_date", project.DueDate.ToString() }
            };


            bool response = mySQLConnector.Execute("INSERT INTO projects (parent_project_id, user_id , name, description, due_date) VALUES (@parent_project_id, @user_id, @name, @description, @due_date)", newProject);

            if (response)
            {
                mySQLConnector.CloseConnections();
                return(true);
            }

            mySQLConnector.CloseConnections();
            return(false);
        }
Exemplo n.º 7
0
 public IActionResult addQuote(string Name, string Quote)
 {
     if (Name == null || Quote == null)
     {
         ViewBag.Message = "Quote and name must be filled out.";
         Console.WriteLine("**************" + Name + "****************");
         Console.WriteLine("**************" + Quote + "****************");
         return(View("Index"));
     }
     else
     {
         Console.WriteLine("******POST********" + Name + "********YEA********");
         Console.WriteLine("******POST********" + Quote + "********YEA********");
         string query = $"insert into quotes (name, quote) values ('{Name}', '{ Quote.Replace( " ' " , " ' ' ")}')";
         System.Console.WriteLine(query);
         MySQLConnector.Execute(query);
         return(Redirect("Quotes"));
     }
     // ViewData["Message"] = "Add Quote";
 }