Beispiel #1
0
        private List <Deadspot> search()
        {
            List <Deadspot> list = new List <Deadspot>();

            connection = new MySqlConnection(connString);
            try
            {
                connection.Open();
                command    = new MySqlCommand(sql, connection);
                dataReader = command.ExecuteReader();
                while (dataReader.Read())
                {
                    Deadspot dspt = new Deadspot();
                    dspt.ProductID      = dataReader.GetInt32(0);
                    dspt.BusinessPlanId = dataReader.GetInt32(1);
                    dspt.Spot           = dataReader.GetString(2);
                    list.Add(dspt);
                }
                dataReader.Close();
                command.Dispose();
                connection.Close();
            }
            catch (Exception ex)
            {
                return(null);
            }

            return(list);
        }
 // POST api/deadspot
 public Deadspot Post(Deadspot deadspot)
 {
     if (deadService.Insert(deadspot))
     {
         return(deadspot);
     }
     return(null);
 }
 // PUT api/deadspot/5
 public Deadspot Put(int id, Deadspot newDeadspot)
 {
     newDeadspot.ProductID = id;
     if (deadService.SearchId(id).Count > 0)
     {
         if (deadService.Edit(newDeadspot))
         {
             return(newDeadspot);
         }
     }
     return(null);
 }
        // DELETE api/deadspot/5
        public Deadspot Delete(int id)
        {
            Deadspot oldDeadspot = new Deadspot();
            var      data        = deadService.SearchId(id);

            if (data.Count > 0)
            {
                oldDeadspot.SetDeadspot(data.ElementAt(0));
                if (deadService.DeleteId(id))
                {
                    return(oldDeadspot);
                }
            }
            return(null);
        }
Beispiel #5
0
 public bool Edit(Deadspot dspt)
 {
     sql = "UPDATE deadspots SET Products_productID='" + dspt.ProductID + "',business_plans_bpID='" + dspt.BusinessPlanId + "',deadSpot='" + dspt.Spot + "' WHERE Products_productID='" + dspt.ProductID + "' AND business_plans_bpID='" + dspt.BusinessPlanId + "'";
     return(EditTable());
 }
Beispiel #6
0
 public bool Insert(Deadspot dspt)
 {
     sql = "INSERT INTO deadspots (Products_productID,business_plans_bpID,deadSpot) VALUES ('" + dspt.ProductID + "'  , '" + dspt.BusinessPlanId + "' , '" + dspt.Spot + "')";
     return(EditTable());
 }