private void listbox_DoubleClick(object sender, EventArgs e) { Globals.index = this.listbox.SelectedIndex; if (Globals.index >= 0) { button6.Visible = true; button7.Visible = true; button8.Visible = true; button9.Visible = true; button11.Visible = true; } if ((Globals.tracker != Globals.index) && (Globals.counterA > 0)) { Globals.counterA = 0; } if (Globals.counterA == 0 && Globals.index != -1) { Globals.tracker = Globals.index; Globals.WPlayer.URL = Globals.songs[Globals.tracker]; Globals.counterA++; Globals.favorites[Globals.tracker] = (Int32.Parse(Globals.favorites[Globals.tracker]) + 1).ToString(); System.IO.File.WriteAllLines("favorite.txt", Globals.favorites); Globals.counterStop = 0; } if (Globals.index != -1) { Info info = new Info(); info.ChangeLabelText(label3, label4, label5, label6, listbox, label8); } favorite info1 = new favorite(); info1.Vale(listBox1); }
public ActionResult AddFavorite(FavoriteViewModel favorite) { //Need to make sure it's not adding favorites that already exist ViewBag.Message = "Your Favorites Page"; var userloggedIn = UserManager.User.employeeID; int selectedActivity = favorite.selectedActivityID; if (selectedActivity != 0) { favorite AddFavorite = new favorite(); AddFavorite.Activity_activityID = selectedActivity; AddFavorite.Employee_employeeID = userloggedIn; // Check if selected activity is already a favorite. If not, add to Favorite Table var existsQuery = from f in db.favorites where (f.Activity_activityID.Equals(AddFavorite.Activity_activityID) && f.Employee_employeeID.Equals(userloggedIn)) select f; if (!existsQuery.Any()) { new FavoriteController().Create(AddFavorite); } } favorite.Activities = db.activities.ToList(); favorite.ActivityNames = new SelectList(favorite.Activities, "activityID", "activityName"); var query = from a in db.activities join b in db.favorites on a.activityID equals b.Activity_activityID where b.Employee_employeeID.Equals(userloggedIn) select new FavoriteViewModel { SelectedActivity = a, SelectedFavorite = b }; favorite.UserFavorites = new SelectList(query.ToArray(), "SelectedFavorite.favoriteID", "SelectedActivity.ActivityName"); return(View("Favorite", favorite)); }
private void Form1_Load(object sender, EventArgs e) { listbox.Items.Clear(); //erases all elements of listbox listBox1.Items.Clear(); //erases all elements of listbox foreach (string line in Globals.songs) { Globals.counter += 1; } for (int i = 0; i < Globals.counter; i++) { try { var file = TagLib.File.Create(Globals.songs[i]); if (file.Tag.Title == null) { listbox.Items.Add("Unknown Title"); } else { listbox.Items.Add(file.Tag.Title); } } catch (System.IO.FileNotFoundException) { MessageBox.Show("A file is missing. ( A song file propably ) "); } } favorite info1 = new favorite(); info1.Vale(listBox1); }
private static bool deleteWorkoutFromList(string _mastersUerName, string _userName, string _workoutName) { bool flag = false; //connect to db db_appEntities db = new db_appEntities(); //check if workout exist in DB favorite delWorkout = checkFavoriteWorkout(_mastersUerName, _userName, _workoutName); if (delWorkout == null) { return(false); } try { db.Entry(delWorkout).State = EntityState.Deleted; db.SaveChanges(); flag = true; } catch (Exception e) { } if (flag == true) { return(true); } else { db.Dispose(); return(false); } }
private void button1_Click(object sender, EventArgs e) { OpenFileDialog mp3 = new OpenFileDialog(); mp3.Filter = "MP3 files (*.mp3)|*.mp3|All files (*.*)|*.*"; if (mp3.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string mp3_name = mp3.FileName; Globals.songs.Add(mp3_name); Globals.favorites.Add("0"); Globals.language.Add("Unknown"); System.IO.File.WriteAllLines("songs.txt", Globals.songs); System.IO.File.WriteAllLines("favorite.txt", Globals.favorites); System.IO.File.WriteAllLines("language.txt", Globals.language); var file = TagLib.File.Create(Globals.songs[Globals.counter]); if (file.Tag.Title == null) { listbox.Items.Add("Unkown Title"); } else { listbox.Items.Add(file.Tag.Title); } Globals.counter++; favorite info1 = new favorite(); info1.Vale(listBox1); } }
public listboxitem_document(string name, string file, Format format, favorite favorite) { this.name = name; this.file = file; this.format = format; this.favorite = favorite; switch (format) { case Format.hwp: this.format_image = "C:\\Users\\user\\Documents\\Visual Studio 2012\\Projects\\MY.DoQ_WPF\\MY.DoQ_WPF\\file_hwp_small.png"; break; case Format.pdf: this.format_image = "C:\\Users\\user\\Documents\\Visual Studio 2012\\Projects\\MY.DoQ_WPF\\MY.DoQ_WPF\\file_pdf_small.png"; break; case Format.ppt: this.format_image = "C:\\Users\\user\\Documents\\Visual Studio 2012\\Projects\\MY.DoQ_WPF\\MY.DoQ_WPF\\file_ppt_small.PNG"; break; case Format.word: this.format_image = "C:\\Users\\user\\Documents\\Visual Studio 2012\\Projects\\MY.DoQ_WPF\\MY.DoQ_WPF\\file_word_small.png"; break; } switch (favorite) { case favorite.YES: this.fav_image = "C:\\Users\\user\\Documents\\Visual Studio 2012\\Projects\\MY.DoQ_WPF\\MY.DoQ_WPF\\favorite_on_small.png"; break; case favorite.NO: this.fav_image = "C:\\Users\\user\\Documents\\Visual Studio 2012\\Projects\\MY.DoQ_WPF\\MY.DoQ_WPF\\favorite_off_small.png"; break; } }
public ActionResult AddToFavorites(string trackId, string artistName, favorite fav) { if (ModelState.IsValid) { using (pushmusicwebEntities re = new pushmusicwebEntities()) { string username = Session["username"].ToString(); var reFav = re.favorite.Where(a => a.user_name == username && a.track_id == trackId).ToList(); if (reFav.Count > 0) { //quand le track est deja dans favorite on le delete de la table var row = re.favorite.Where(d => d.track_id == trackId && d.user_name == username).First(); re.favorite.Remove(row); re.SaveChanges(); return(Json(new { success = false, responseText = artistName + "'s track removed successfully!" }, JsonRequestBehavior.AllowGet)); } else { //sinon on l'ajoute dans la table favorite favorite fa = new favorite(); fa.user_name = Session["username"].ToString(); fa.track_id = trackId; fa.artist_name = artistName; re.favorite.Add(fa); re.SaveChanges(); return(Json(new { success = true, responseText = artistName + "'s track added successfully!" }, JsonRequestBehavior.AllowGet)); } } } return(Json(new { success = false, responseText = "Something went wrong in our end. Please try again at a later time" }, JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> Create([Bind("id,fkuser,fkproject")] favorite favorite, int fkuser, int fkproject) { if (ModelState.IsValid) { var userid = HttpContext.Session.GetInt32("userid"); var currentUser = await _context.users.FirstOrDefaultAsync(m => m.id == userid); if (currentUser == null) { return(RedirectToAction("customErrorPage", "user")); } else { var currentProject = await _context.projects.FirstOrDefaultAsync(m => m.id == fkproject); if (currentProject == null) { return(RedirectToAction("customErrorPage", "user")); } else { favorite.fkproject = currentProject; favorite.fkuser = currentUser; _context.Add(favorite); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } } return(View(favorite)); }
protected void Page_Load(object sender, EventArgs e) { if (User.Identity.IsAuthenticated) { Response.Cache.SetCacheability(HttpCacheability.NoCache); if (!tool.StrIsNullOrEmpty(Request["nid"])) { int nid = Convert.ToInt32(Request["nid"]); int uid = Convert.ToInt32(User.Identity.Name); if (db.favorite.Where(d => d.nid == nid && d.uid == uid).Count() == 0) { favorite f = new favorite(); favoriteRepository fr = new favoriteRepository(db); f.id = fr.MaxId() + 1; f.nid = nid; f.uid = uid; fr.Add(f); } else { Response.Write("已经被收藏"); } Response.Write("添加成功"); } } else { Response.Write("1"); } }
async void OnFavClicked(object sender, EventArgs e) { SearchParameters sp = new SearchParameters() { SearchMode = SearchMode.All, }; sp.Filter = "Address eq '" + address.Text + "'"; var response = indexClient.Documents.Search <favorite>("*", sp); SearchResult <favorite> result = response.Results[0]; var bb = new favorite { ID = result.Document.ID, Mamaname = result.Document.Mamaname, Snackname = result.Document.Snackname, Address = result.Document.Address, }; //var fav = (favorite)result.Document; //var favo = (favorite)SPECIFIC; await App.Database.SaveItemAsync(bb); Fav.Text = "お気に入り登録済"; Fav.TextColor = Color.LightGray; Fav.BackgroundColor = Color.LightYellow; // await Navigation.PopAsync(); //この後に登録しましたのポップ }
public async Task <IActionResult> createFavorite(int userid, int projectid) { favorite favorite = new favorite(); if (ModelState.IsValid) { var currentUser = await _context.users.FirstOrDefaultAsync(m => m.id == userid); if (currentUser == null) { return(NotFound()); } else { var currentProject = await _context.projects.FirstOrDefaultAsync(m => m.id == projectid); if (currentProject == null) { return(NotFound()); } else { favorite.fkproject = currentProject; favorite.fkuser = currentUser; _context.Add(favorite); await _context.SaveChangesAsync(); return(Json(favorite)); } } } return(Json(favorite)); }
public ActionResult DeleteConfirmed(int id) { favorite favorite = db.favorites.Find(id); db.favorites.Remove(favorite); db.SaveChanges(); return(RedirectToAction("Index")); }
public ApiMessage <bool> IsFavorite(string id) { var model = new favorite(); model.ProductID = id; model.UserID = UserInfo.Id; return(fbll.Exists(model)); }
public async Task <ActionResult> DeleteConfirmed(int id) { favorite favorite = await db.favorite.FindAsync(id); db.favorite.Remove(favorite); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public ApiMessage <bool> Exists(favorite parm) { var msg = _db.Query <favorite> (@"SELECT * FROM FAVORITE WHERE UserID=@UserID AND ProductID=@ProductID", parm); var api = new ApiMessage <bool>() { Data = msg.Any() }; return(api); }
public ActionResult AddToFavorites(long id) { mytable mytable = db.mytables.Find(id); favorite fav = new favorite(); fav.restaurant_name = mytable.name; fav.user = User.Identity.GetUserId(); db.favorites.Add(fav); db.SaveChanges(); return(RedirectToAction("Index")); }
//[HttpPost] //[ValidateAntiForgeryToken] //public ActionResult MakeReservation([Bind(Include = "Id,user,,restaurant_name")] favorite favorite) //{ // var favorite1= new favorite(); // var userID = User.Identity.GetUserId(); // favorite1.restaurant_name = favorite.restaurant_name; // favorite1.Id = favorite.Id; // favorite1.user = userID; // db.favorites.Add(favorite1); // db.SaveChanges(); // return RedirectToAction("Index"); //} public ActionResult RemoveFromFavorites(long id) { favorite fav = db.favorites.Find(id); db.favorites.Remove(fav); db.SaveChanges(); return(RedirectToAction("Index")); //return View(); }
public ActionResult Edit([Bind(Include = "favoriteID,Employee_employeeID,Activity_activityID")] favorite favorite) { if (ModelState.IsValid) { db.Entry(favorite).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Activity_activityID = new SelectList(db.activities, "activityID", "activityName", favorite.Activity_activityID); ViewBag.Employee_employeeID = new SelectList(db.employees, "employeeID", "employeeFirstName", favorite.Employee_employeeID); return(View(favorite)); }
private string BuildInsertCommand(favorite pack) { String command; StringBuilder sb = new StringBuilder(); // use a string builder to create the dynamic string sb.AppendFormat("Values('{0}','{1}','{2}',{3})", pack.Airline, pack.CityFrom, pack.CityTo, pack.NumOfLike); String prefix = "INSERT INTO favoriteFlight_2020_ori " + "(Airline,CityFrom,CityTo,NumberOfLike) "; command = prefix + sb.ToString(); return command; }
public ActionResult Edit([Bind(Include = "idfavorite,account_idAccount,item_iditem")] favorite favorite) { if (ModelState.IsValid) { db.Entry(favorite).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.account_idAccount = new SelectList(db.account, "idAccount", "name", favorite.account_idAccount); ViewBag.item_iditem = new SelectList(db.item, "iditem", "name", favorite.item_iditem); return(View(favorite)); }
public async Task <ActionResult> Edit([Bind(Include = "Id,user_id,card_id")] favorite favorite) { if (ModelState.IsValid) { db.Entry(favorite).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.user_id = new SelectList(db.AspNetUsers, "Id", "UserName", favorite.user_id); ViewBag.card_id = new SelectList(db.cards, "Id", "text", favorite.card_id); return(View(favorite)); }
public void RemoveFromFavorites(RemoveFavoriteRequest request) { WeatherDbDataContext db = new WeatherDbDataContext(connectString); //Create new Employee favorite fav = db.favorites.FirstOrDefault(x => x.key == request.key); //Add new Employee to database db.favorites.DeleteOnSubmit(fav); //Save changes to Database. db.SubmitChanges(); }
// GET: Favorite/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } favorite favorite = db.favorites.Find(id); if (favorite == null) { return(HttpNotFound()); } return(View(favorite)); }
// GET: favorites/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } favorite favorite = await db.favorite.FindAsync(id); if (favorite == null) { return(HttpNotFound()); } return(View(favorite)); }
public void InsertOrUpdate(favorite favorite) { //if (favorite.favoriteID == default(int)) if (Find(favorite.favoriteID) == null) { // New entity context.favorites.Add(favorite); } else { // Existing entity context.Entry(favorite).State = EntityState.Modified; } }
private static favorite checkFavoriteWorkout(string _masterUserName, string _userName, string _workoutName) { //connect to db db_appEntities db = new db_appEntities(); //get workout by workoutName favorite _workout = db.favorites.Where(x => x.masterUser == _masterUserName && x.userName == _userName && x.workoutName == _workoutName).SingleOrDefault(); db.Dispose(); //check if workout exist and if workoutName is correct if (_workout == null) { return(null); } return(_workout); }
// GET: favorites/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } favorite favorite = db.favorite.Find(id); if (favorite == null) { return(HttpNotFound()); } ViewBag.account_idAccount = new SelectList(db.account, "idAccount", "name", favorite.account_idAccount); ViewBag.item_iditem = new SelectList(db.item, "iditem", "name", favorite.item_iditem); return(View(favorite)); }
// GET: favorites/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } favorite favorite = await db.favorite.FindAsync(id); if (favorite == null) { return(HttpNotFound()); } ViewBag.user_id = new SelectList(db.AspNetUsers, "Id", "UserName", favorite.user_id); ViewBag.card_id = new SelectList(db.cards, "Id", "text", favorite.card_id); return(View(favorite)); }
// GET: Favorite/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } favorite favorite = db.favorites.Find(id); if (favorite == null) { return(HttpNotFound()); } ViewBag.Activity_activityID = new SelectList(db.activities, "activityID", "activityName", favorite.Activity_activityID); ViewBag.Employee_employeeID = new SelectList(db.employees, "employeeID", "employeeFirstName", favorite.Employee_employeeID); return(View(favorite)); }
public int SetFavorite(string username, string[][] idList, int isAdd) { List <favorite> selectedList = entities.favorite.Where(f => f.username == username).ToList(); // isAdd add single record if (isAdd == 1) { if (!selectedList.Exists(f => f.locationName == idList[0][0])) { favorite fav = new favorite(); fav.username = username; fav.locationName = idList[0][0]; fav.location = idList[0][1]; entities.favorite.Add(fav); entities.SaveChanges(); return(1); } } else // is not add, delete current old record and add new { entities.favorite.RemoveRange(selectedList); entities.SaveChanges(); List <favorite> newList = new List <favorite>(); foreach (string[] ids in idList) { favorite fav = new favorite(); fav.username = username; fav.locationName = ids[0]; fav.location = ids[1]; newList.Add(fav); } entities.favorite.AddRange(newList); entities.SaveChanges(); return(1); } return(0); }
public void insertFavorite(favorite f) { DALfavorites.insert(f); }
partial void Insertfavorite(favorite instance);
partial void Updatefavorite(favorite instance);
partial void Deletefavorite(favorite instance);
private void attach_favorites(favorite entity) { this.SendPropertyChanging(); entity.User = this; }
private void detach_favorites(favorite entity) { this.SendPropertyChanging(); entity.User = null; }