Ejemplo n.º 1
0
 public ActionResult Favorites(string city_name, string country_code)
 {
     using (WeatherDataEntities dc = new WeatherDataEntities())
     {
         var favdb = dc.favourites.ToList <favourite>();
         var email = Session["LoggedEmail"];
         var pass  = Session["LoggedUsername"];
         int favCount;
         if (System.Web.HttpContext.Current.Session["LoggedUsername"] != null)
         {
             favCount = favdb.Where(fv => fv.Email == email.ToString() && city_name.Equals(fv.CityName)).Count();
             if (favCount > 0)
             {
                 string fv = "Favourite city already added..!";
                 return(Json(fv, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 favourite fav = new favourite();
                 fav.CityName = city_name;
                 fav.Email    = email.ToString();
                 fav.Zipcode  = country_code;
                 dc.favourites.Add(fav);
                 dc.SaveChanges();
                 string fv = "Favourite city saved successfully";
                 return(Json(fv, JsonRequestBehavior.AllowGet));
             }
         }
         else
         {
             return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
         }
     }
 }
Ejemplo n.º 2
0
        public IHttpActionResult getFavourites([FromBody] favourite data)
        {
            favourite fav = new favourite();

            fav.id_word = data.id_word;
            fav.id_user = data.id_user;
            api.favourites.Add(fav);
            api.SaveChanges();
            return(Ok(fav));
        }
Ejemplo n.º 3
0
        public static Player LoadPlayer(string name, int userConn)
        {
            Player load = new Player();

            try
            {
                //string path = (@"players\" + name.Substring(0, 1) + @"\" + name.ToLower() + ".xml").ToLower();
                //string path = Path.Combine(Server.userFilePath,("players" + Path.DirectorySeparatorChar + name.Substring(0, 1).ToUpper() + Path.DirectorySeparatorChar + name.ToLower() + ".xml"));
                string path = Path.Combine(Server.userFilePath, @"players" + Path.DirectorySeparatorChar + name.ToLower() + ".xml");

                Debug.Print(Path.GetFullPath(path));

                if (File.Exists(path))
                {
                    try
                    {
                        XmlSerializer deserial   = new XmlSerializer(typeof(Player));
                        TextReader    textReader = new StreamReader(@path);
                        load = (Player)deserial.Deserialize(textReader);
                        textReader.Close();
                        load.NewPlayer = false;
                    }
                    catch (Exception e)
                    {
                        Debug.Print(e.ToString());
                        load = null;
                    }
                }
                else
                {
                    load           = new Player();
                    load.NewPlayer = true;
                }
                if (load.favourites.Count < 3)
                {
                    favourite f = new favourite();
                    f.type  = "";
                    f.value = "";
                    for (int i = load.favourites.Count; i < 3; i++)
                    {
                        load.favourites.Add(f);
                    }
                }
            }
            catch (Exception ex)
            {
                Connection.logError(ex.ToString(), "Player");
            }

            return(load);
        }
Ejemplo n.º 4
0
 public ApiResponse <Boolean> testFavourites([FromBody] favourite data)
 {
     if (api.favourites.Where(m => m.id_word == data.id_word).Any())
     {
         return(new ApiResponse <Boolean> {
             error = 0, message = "Da ton tai", data = true
         });
     }
     else
     {
         return(new ApiResponse <Boolean> {
             error = 1, message = "chua ton tai", data = false
         });
     }
 }
Ejemplo n.º 5
0
        public ActionResult deleteFavourite(int id)
        {
            favourite gelenProgram = db.favourite.Where(f => f.program_id == id).FirstOrDefault();

            if (gelenProgram != null)
            {
                db.favourite.Remove(gelenProgram);
                db.SaveChanges();
                TempData["alert"] = "<div class='alert alert-success' style='margin-top:10px;max-width:60%;margin-left:auto;margin-right:auto;'> <strong> Başarılı ! </strong> Program favorilerinizden silindi... </div>";
                return(RedirectToAction("Favourite", "programs"));
            }
            else
            {
                TempData["alert"] = "<div class='alert alert-danger' style='margin-top:10px;max-width:60%;margin-left:auto;margin-right:auto;'> <strong> Hata ! </strong> Program favorilerinizden silinemedi. Bu program zaten favorilerinizde olmayabilir mi ? </div>";
                return(RedirectToAction("Favourite", "programs"));
            }
        }
Ejemplo n.º 6
0
        public ActionResult addFavourite(int id)
        {
            List <favourite> Begenilenler = db.favourite.ToList();

            favourite varMi = Begenilenler.Where(i => i.program_id == id && i.user_id == Convert.ToInt32(Session["user_id"])).FirstOrDefault();

            if (varMi == null)
            {
                var favourite = new favourite();
                favourite.program_id = id;
                favourite.user_id    = Convert.ToInt32(Session["user_id"]);
                db.favourite.Add(favourite);
                db.SaveChanges();
                TempData["alert"] = "<div class='alert alert-success' style='margin-top:10px;max-width:60%;margin-left:auto;margin-right:auto;'> <strong> Başarılı ! </strong> Program favorilerinize eklendi.. </div>";
            }

            db.SaveChanges();
            return(RedirectToAction("details", "programs", new { id = id }));
        }
Ejemplo n.º 7
0
        public ActionResult favourite(int fav)
        {
            int UI = (int)Session["UserId"];
            int MI = (int)Session["MovieId"];

            if (fav == 1)
            {
                favourite fa = new favourite();
                fa.userId = UI; fa.movieId = MI;
                db.Favourite.Add(fa);
                db.SaveChanges();
            }
            else
            {
                var c = db.Favourite.Where(y => y.movieId == MI && y.userId == UI).FirstOrDefault();

                db.Favourite.Remove(c);
                db.SaveChanges();
            }
            return(Content("hi fav"));
        }
Ejemplo n.º 8
0
 public void AddFavourite(favourite fav)
 {
     db.favourites.InsertOnSubmit(fav);
     db.SubmitChanges();
 }
Ejemplo n.º 9
0
 public IHttpActionResult delFavourites([FromBody] favourite data)
 {
     api.favourites.Remove(api.favourites.Where(m => m.id == data.id && m.id_user == data.id_user).FirstOrDefault());
     api.SaveChanges();
     return(Ok());
 }