예제 #1
0
 internal void CreateCleaning(CleaningDTO cleaning)
 {
     if (!HotelApiClient.GetInstance().CreateCleaning(cleaning))
     {
         MessageBox.Show("gg");
     }
 }
예제 #2
0
        public CleaningDTO Read(int cleaningID)
        {
            using var connection = Connection.GetConnection();
            {
                connection.OpenAsync();

                using var command   = connection.CreateCommand();
                command.CommandText = "SELECT * FROM `Cleaning` WHERE CleaningID = @cleaningID";
                command.Parameters.AddWithValue("@cleaningID", cleaningID);

                var reader = command.ExecuteReader();

                if (!reader.Read())
                {
                    return(null);
                }

                var cleaningobj = new CleaningDTO()
                {
                    CleaningID  = reader.GetInt32("CleaningID"),
                    BusID       = reader.GetInt32("BusID"),
                    TimeCleaned = reader.GetDateTime("TimeCleaned"),
                    CleanedBy   = reader.GetInt32("CleanedBy"),
                    Type        = reader.GetInt32("Type"),
                    Status      = reader.GetInt32("Status")
                };
                return(cleaningobj);
            }
        }
예제 #3
0
        public IActionResult CreateCleaning([FromBody] CleaningDTO cleaning)
        {
            if (!Request.Cookies.ContainsKey("sessid"))
            {
                return(BadRequest());
            }
            var sessid   = Request.Cookies["sessid"];
            var persBook = _authService.GetAuthorized(sessid)?.EmplBook;

            _hotelService.CreateCleaning(cleaning, persBook);
            return(NoContent());
        }
예제 #4
0
 public void AddTramToCleaning(ConductorView Train)
 {
     if (Train.Cleaning == true)
     {
         CleaningDTO cleaning = new CleaningDTO()
         {
             TramNumber = Train.TramNumber, Annotation = "de tram licht vol met bierblikjes van carnaval."
         };
         DataBase.AddCleaning(cleaning);
     }
     if (Train.Maintenance == true)
     {
         MaintenanceDTO maintenance = new MaintenanceDTO()
         {
             TramNumber = Train.TramNumber, Annotation = "de trams remmen maken een gek geluid"
         };
         DataBase.AddService(maintenance);
     }
 }
예제 #5
0
 public bool RemoveCleaning(CleaningDTO cleaning)
 {
     try
     {
         _connect.Con.Open();
         MySqlCommand cmd = _connect.Con.CreateCommand();
         cmd.CommandText = "DELETE FROM cleaning WHERE idTram = (SELECT idTram FROM Tram WHERE Number = @TramNumber)";
         //TODO: require AuthKey
         cmd.Parameters.AddWithValue("@TramNumber", cleaning.TramNumber);
         cmd.ExecuteNonQuery();
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         _connect.Con.Close();
     }
     return(true);
 }
예제 #6
0
 private bool RemoveCleaning(CleaningView cleaningView)
 {
     try
     {
         var cleaning = new CleaningDTO();
         cleaning.TramNumber = cleaningView.TargetNumber;
         cleaning.AuthKey    = cleaningView.Key;
         if (this.DatabaseMaintenance.RemoveCleaning(cleaning))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
예제 #7
0
        public bool Create(CleaningDTO cleaningDTO)
        {
            using var connection = Connection.GetConnection();
            {
                try
                {
                    using var command = connection.CreateCommand();

                    command.CommandText = "INSERT INTO Cleaning(BusID, CleanedBy, TimeCleaned, Type, Status) VALUES(@busID, @cleanedBy, @timeCleaned, @type, @status);";
                    command.Parameters.AddWithValue("@busID", cleaningDTO.BusID);
                    command.Parameters.AddWithValue("@cleanedBy", cleaningDTO.CleanedBy);
                    command.Parameters.AddWithValue("@timeCleaned", cleaningDTO.TimeCleaned);
                    command.Parameters.AddWithValue("@type", cleaningDTO.Type);
                    command.Parameters.AddWithValue("@status", cleaningDTO.Status);

                    connection.Open();
                    command.ExecuteNonQuery();
                    connection.Close();
                    return(true);
                }
                catch { connection.Close(); return(false); }
            }
        }
예제 #8
0
 public bool AddCleaning(CleaningDTO cleaning)
 {
     try
     {
         _connect.Con.Open();
         MySqlCommand cmd = _connect.Con.CreateCommand();
         cmd.CommandText = "INSERT INTO `cleaning` (`idTram`, `Size`, `Priority`, `Description`) VALUES ((SELECT idTram FROM Tram WHERE Number = @TramNumber), @Size, @Priority, @Desc)";
         cmd.Parameters.AddWithValue("@TramNumber", cleaning.TramNumber);
         cmd.Parameters.AddWithValue("@Size", 1);
         cmd.Parameters.AddWithValue("@Priority", cleaning.Urgent);
         cmd.Parameters.AddWithValue("@Desc", cleaning.Annotation);
         cmd.ExecuteNonQuery();
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         _connect.Con.Close();
     }
     return(true);
 }
예제 #9
0
 public bool IndicateCompleteCleaning(CleaningView cleaning)
 {
     try
     {
         CleaningDTO completedCleaning = new CleaningDTO();
         completedCleaning.TramNumber = cleaning.TargetNumber;
         completedCleaning.AuthKey    = cleaning.Key;
         completedCleaning.Annotation = cleaning.TargetAnnotation;
         if (this.DatabaseMaintenance.IndicateCompleteCleaning(completedCleaning))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
예제 #10
0
        public List <CleaningDTO> GetCleaningList()
        {
            List <CleaningDTO> cleaningList = new List <CleaningDTO>();

            try
            {
                _connect.Con.Open();
                string query = "SELECT Tram.Number, cleaning.Size, cleaning.Priority, cleaning.Description FROM cleaning"
                               + " INNER JOIN Tram ON Tram.idTram = cleaning.idTram";
                MySqlCommand cmd        = new MySqlCommand(query, _connect.Con);
                var          dataReader = cmd.ExecuteReader();

                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        CleaningDTO cleaning = new CleaningDTO
                        {
                            TramNumber = dataReader.GetInt32("Number"),
                            Annotation = dataReader.GetString("Description"),
                            Urgent     = dataReader.GetBoolean("Priority")
                        };
                        cleaningList.Add(cleaning);
                    }
                }
                dataReader.Close();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                _connect.Con.Close();
            }
            return(cleaningList);
        }
예제 #11
0
 public bool IndicateCompleteCleaning(CleaningDTO cleaning)
 {
     try
     {
         _connect.Con.Open();
         MySqlCommand cmd = _connect.Con.CreateCommand();
         cmd.CommandText = "INSERT INTO `cleaninghistory` (`idTram`, `idUser`, `CleaningDate`, `Description`) VALUES ((SELECT idTram FROM Tram WHERE Number = @TramNumber), (SELECT idUser FROM authorisationlist WHERE UniqueKey = @AuthKey), @Date, @Annotation)";
         cmd.Parameters.AddWithValue("@TramNumber", cleaning.TramNumber);
         cmd.Parameters.AddWithValue("@AuthKey", cleaning.AuthKey);
         cmd.Parameters.AddWithValue("@Annotation", cleaning.Annotation);
         cmd.Parameters.AddWithValue("@Date", DateTime.Now);
         cmd.ExecuteNonQuery();
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         _connect.Con.Close();
     }
     RemoveCleaning(cleaning);
     return(true);
 }
예제 #12
0
 private bool AddCleaning(CleaningView cleaningView)
 {
     try
     {
         var cleaning = new CleaningDTO();
         cleaning.TramNumber = cleaningView.TargetNumber;
         cleaning.Annotation = cleaningView.TargetAnnotation;
         cleaning.AuthKey    = cleaningView.Key;
         //TODO: add IsLarge bool to DTO
         if (this.DatabaseMaintenance.AddCleaning(cleaning))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
예제 #13
0
        public bool CreateCleaning(CleaningDTO cleaning)
        {
            var resp = Client.PostAsJsonAsync("api/cleanings", cleaning).Result;

            return(resp.IsSuccessStatusCode);
        }