Exemplo n.º 1
0
        public int addToFavorite(favorite pack)
        {
            DBservices dbs = new DBservices();

            dbs    = dbs.readFavoriteTable();
            dbs.dt = addOrIncrease(pack, dbs.dt);
            dbs.update();
            return(0);
        }
Exemplo n.º 2
0
        private DataTable addOrIncrease(favorite pack, DataTable dt)
        {
            foreach (DataRow dr in dt.Rows)
            {
                string airline  = (string)dr["AirLine"];
                string cityFrom = (string)dr["CityFrom"];
                string cityTo   = (string)dr["CityTo"];
                if (pack.Airline == airline && pack.CityFrom == cityFrom && pack.CityTo == cityTo)
                {
                    int numOfLike = Convert.ToInt32(dr["NumberOfLike"]);
                    dr["NumberOfLike"] = numOfLike + 1;
                    return(dt);
                }
            }
            DBservices dbs1        = new DBservices();
            int        numEffected = dbs1.addNewFavorite(pack);

            return(dt);
        }