public void RemoveFav(int favId) { Fav fav = unitOfWork.FavDal.Find(m => m.FavId == favId); unitOfWork.FavDal.Remove(fav); unitOfWork.Complete(); }
public static IEnumerable <City> GetFavoriteCities(List <string> FavoritesIndexData) { List <City> AirportsList = new List <City>(); try { foreach (string Fav in FavoritesIndexData) { XElement xdoc = XElement.Load("/AirportWeatherPro;component/Resources/Cities.xml"); var Result = from e in xdoc.Descendants("City") where e.Element("AirportCode").Value.Equals(Fav.Replace("`", string.Empty)) select new { cityname = e.Element("CityName"), airportname = e.Element("AirportName"), airportcode = e.Element("AirportCode"), }; foreach (var k in Result) { City city = new City(); city.Name = k.cityname.Value; city.AirportName = k.airportname.Value; city.AirportCode = k.airportcode.Value; city.AirportImage = "/AirportWeatherPro;component/Images/Airports/" + k.airportcode.Value + ".png"; city.AirportIsFavoriteIcon = "/AirportWeatherPro;component/Images/minus.png"; AirportsList.Add(city); } } return(AirportsList); } catch (Exception) { return(null); } }
public void UIInit(RemoteMain main, DeviceListScene list, MainBGScene mainBg, Fav fav) { _Main = main; _List = list; _UI = mainBg; _Fav = fav; }
public bool AddFav(Fav fav) { using (OracleConnection connection = new OracleConnection(_connectionString)) { using (OracleCommand command = new OracleCommand("SP_INSERT_FAV")) { connection.Open(); using (OracleDataAdapter dataAdapter = new OracleDataAdapter()) { command.CommandType = CommandType.StoredProcedure; OracleParameter[] prm = new OracleParameter[2]; prm[0] = command.Parameters.Add("v_MEMBER_ID", OracleDbType.Int32, fav.User.UserId, ParameterDirection.Input); prm[1] = command.Parameters.Add("v_BOOK_ID", OracleDbType.Int32, fav.Book.BookId, ParameterDirection.Input); command.Connection = connection; try { command.ExecuteNonQuery(); connection.Close(); return(true); } catch { connection.Close(); return(false); }; } } } }
public int favDelete(int id) { Fav find = unitOfWork.FavDal.Find(m => m.FavId == id); unitOfWork.FavDal.Remove(find); return(unitOfWork.Complete()); }
public InputFavInfosPresenter(IInputFavInfosView view, FavoritesRepository favorites, FavoriteModifiedEventArgs e) { this.view = view; this.favorites = favorites; this.mode = InputFavMode.MODIFICATION; this.toEdit = e.Modified; this.FinishSetup(e.Modified.Name, e.Modified.Uri.AbsoluteUri); }
public void InsertFav(int id, string login) { if (!FavExists(id, login)) { Fav f = new Fav(id, login); _context.Fav.Add(f); _context.SaveChanges(); } }
public ActionResult Update(int id, Fav fav) { Fav findFav = _favServices.favDetails(id); findFav.Customer = fav.Customer; findFav.Product = fav.Product; int s = _favServices.favUpdate(); return(RedirectToAction("getFav", "AdminFav")); }
public void RemoveFav(int id, string login) { if (FavExists(id, login)) { //List<Fav> list = _context.Fav.Where(e => e.CharacterId == id).ToList(); Fav fav = new Fav(); fav = _context.Fav.Find(id, login); _context.Fav.Remove(fav); _context.SaveChanges(); } }
public IActionResult SetLikedStatus(SetLikedStatusDto setLikedStatusDto) { var user = _context.Users .SingleOrDefault(user => user.userName == setLikedStatusDto.UserName); if (user == null) { return(BadRequest("Нет такого пользователя")); } var liked = _context.Favs .SingleOrDefault(f => f.TrackId == setLikedStatusDto.TrackId && f.UserId == user.Id); if (liked == null) { // Песня не добавлена в избранное данным пользователем. if (setLikedStatusDto.LikedStatus) { // Добавление песни в избранное. var newFav = new Fav(); newFav.TrackId = setLikedStatusDto.TrackId; newFav.UserId = user.Id; try { _context.Favs.Add(newFav); _context.SaveChanges(); } catch (System.Exception error) { return(BadRequest(error.Message)); } } return(NoContent()); } // Песня добавлена в избранное данным пользователем. if (!setLikedStatusDto.LikedStatus) { // Удаление песни из избранного. try { _context.Favs.Remove(liked); _context.SaveChanges(); } catch (System.Exception error) { return(BadRequest(error.Message)); } } return(NoContent()); }
public void CommunicatorInit(RemoteMain main, AARController aar, UIActor actor, MsgController control, Fav fav) { _AAR = aar; _Msg = control; _Main = main; _Actor = actor; _Fav = fav; _MsgSaver = new List <byte[]>(); _State = COMMUICATOR_STATE.CS_DISCONNECT; }
public void DeleteSingleFav(Fav fav) { using (OracleConnection connection = new OracleConnection(_connectionString)) { using (OracleCommand command = connection.CreateCommand()) { connection.Open(); command.BindByName = true; command.Parameters.Add("userId", fav.User.UserId); command.Parameters.Add("bookId", fav.Book.BookId); command.CommandText = "Delete From FAVORITES Where BOOK_ID = :bookId AND MEMBER_ID = :userId"; command.ExecuteNonQuery(); } } }
void Start() { _AAR = AARController.Instance; _Msg = MsgController.instance; _Bth = BthCommunicator.instance; _UI = UIActor.instance; _List = DeviceListScene.instance; _Main = MainBGScene.instance; _Fav = Fav.instance; _Alert = AlertManager.instance; Screen.SetResolution(800, 1280, true); Screen.orientation = ScreenOrientation.Portrait; MainInit(); }
public void AddUserToFav() { Login login = new Login(Driver); Assert.True(login.MatchLogin(ConfigurationManager.AppSettings["login_email"], "asdf1234")); MyMatch myMatch = new MyMatch(Driver); Random r = new Random(); string DynamicZip = "2820" + r.Next(1, 9).ToString(); myMatch.SearchMatches("I am a MAN looking for WOMEN", "25", "35", "100", DynamicZip); Search mySearch = new Search(Driver); mySearch.AddRandomUserToFav(); Fav myFav = new Fav(Driver); myFav.VerifyAddedFavCard(mySearch.SelectedUserName); login.SignOut(); }
public int Insert(Fav fav) { string DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; SqlConnection conn = new SqlConnection(DBConnect); string sqlStmt = "INSERT INTO Favs (uid, sid)" + "VALUES (@paraUid, @paraSid)"; int result = 0; SqlCommand sqlCmd = new SqlCommand(sqlStmt, conn); sqlCmd.Parameters.AddWithValue("@paraUid", fav.uid); sqlCmd.Parameters.AddWithValue("@paraSid", fav.sid); conn.Open(); result = sqlCmd.ExecuteNonQuery(); conn.Close(); return(result); }
// GET: Fav public ActionResult AddToFav(int id) { Customer customer = Session["loginCustomer"] as Customer; if (customer != null) { Product product = productServices.GetProductById(id); Fav fav = new Fav() { CustomerId = customer.CustomerId, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, productID = product.ProductId }; favServices.AddFav(fav); return(RedirectToAction("Details", "Product", new { id = id })); } return(RedirectToAction("Index", "Home")); }
public void favourite(string sid) { if (Session["uid"] != null) { string currUserId = Session["uid"].ToString(); List <string> userFavs = new Fav().SelectUserFavs(currUserId); List <BL.service.Service> serv = new BL.service.Service().SelectById(sid); if (!userFavs.Contains(sid)) { new BL.service.Service().Favourite(sid, serv[0].favs + 1); Fav fav = new Fav(int.Parse(currUserId), int.Parse(sid)); int result = fav.Add(); if (result == 1) { Toast.success(this, "Service favourited"); } else { Toast.error(this, "An error occured while favouriting service"); } } else { new BL.service.Service().Favourite(sid, serv[0].favs - 1); int result = new Fav().Remove(int.Parse(currUserId), int.Parse(sid)); if (result == 1) { Toast.success(this, "Service unfavourited"); } else { Toast.error(this, "An error occured while unfavouriting service"); } } } else { Toast.error(this, "You need to be logged in to favourite a service"); } }
public FavoriteModifiedEventArgs(Fav modified) { this.Modified = modified; }
public bool AddFav([FromBody] Fav fav) { return(favService.AddFav(fav)); // added return true otherwise there is a fav in table so return false }
public void AddFav(Fav fav) { unitOfWork.FavDal.Add(fav); unitOfWork.Complete(); }
public void Delete(Fav entity) { _favRepository.Delete(entity); }
public void Update(Fav entity) { _favRepository.Update(entity); }
public ActionResult Update(int id) { Fav fav = _favServices.favDetails(id); return(View(fav)); }
public void DeleteSingleFavorite([FromBody] Fav fav) { favService.DeleteSingleFav(fav); }
protected void Page_Load(object sender, EventArgs e) { if (Session["success"] != null) { Toast.success(this, Session["success"].ToString()); Session["success"] = null; } if (Session["error"] != null) { Toast.error(this, Session["error"].ToString()); Session["error"] = null; } if (Session["uid"] != null) { LblUid.Text = Session["uid"].ToString(); User user = getCurrUser(); bio.InnerHtml = user.bio; website.InnerHtml = user.website; dob.InnerHtml = user.birthday; gender.InnerHtml = user.gender; location.InnerHtml = user.location; occupation.InnerHtml = user.occupation; email.InnerHtml = user.email; currUsername.InnerHtml = user.username; string[] social = user.social.Split(','); List <string> socialList = new List <string>(social); twitter.HRef = socialList[0]; insta.HRef = socialList[1]; facebook.HRef = socialList[2]; youtube.HRef = socialList[3]; deviant.HRef = socialList[4]; string[] userSkills = user.skills.Split(','); List <string> skillList = new List <string>(); foreach (string skill in userSkills) { if (skill != "") { skillList.Add(skill); } } if (skillList.Count < 1) { noskill.Visible = true; } skillsRepeater.DataSource = skillList; skillsRepeater.DataBind(); if (user.type == "client") { usertype.InnerHtml = "Client"; } string dirPath = "~/Content/uploads/profile/" + LblUid.Text + "/"; if (File.Exists(Server.MapPath(dirPath) + "banner.png")) { userBanner.ImageUrl = Page.ResolveUrl(dirPath + "banner.png"); } if (File.Exists(Server.MapPath(dirPath) + "profilePic.png")) { userProfilePic.ImageUrl = Page.ResolveUrl(dirPath + "profilePic.png"); } followers.InnerHtml = user.followers.ToString(); following.InnerHtml = user.following.ToString(); followerTitle.InnerHtml = user.username + "'s followers"; followingTitle.InnerHtml = user.username + "'s following"; List <string> userFavs = new Fav().SelectUserFavs(LblUid.Text); List <BL.service.Service> servFavs = new List <BL.service.Service>(); foreach (string favs in userFavs) { List <BL.service.Service> service = new BL.service.Service().SelectById(favs); servFavs.Add(service[0]); } List <BL.service.Service> services = new BL.service.Service().SelectByUid(LblUid.Text); servList.DataSource = services; servList.DataBind(); favList.DataSource = servFavs; favList.DataBind(); List <string> followingIds = new Follow().SelectFollowing(LblUid.Text); List <User> usersFollowing = new List <User>(); foreach (string id in followingIds) { User followingUser = new User().SelectById(id); usersFollowing.Add(followingUser); } followingRepeater.DataSource = usersFollowing; followingRepeater.DataBind(); List <string> followerIds = new Follow().SelectFollowers(LblUid.Text); List <User> usersFollower = new List <User>(); foreach (string id in followerIds) { User followerUser = new User().SelectById(id); usersFollower.Add(followerUser); } followerRepeater.DataSource = usersFollower; followerRepeater.DataBind(); if (followingRepeater.Items.Count == 0) { noFollowing.Visible = true; } if (followerRepeater.Items.Count == 0) { noFollower.Visible = true; } if (!Page.IsPostBack) { List <Portfolio> portfolios = new Portfolio().SelectByUid(int.Parse(LblUid.Text)); projects.DataSource = portfolios; projects.DataBind(); if (portfolios.Count < 1) { noProj.Visible = true; } } } else { Session["error"] = "You need to be logged in to edit your profile"; Response.Redirect("~/Views/index.aspx"); } }
protected void favList_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "view") { string serviceId = e.CommandArgument.ToString(); List <BL.service.Service> service = new BL.service.Service().SelectById(serviceId); BL.service.Service curr = new BL.service.Service(); curr.UpdateViews(serviceId, service[0].views + 1); Response.Redirect("~/Views/service/index.aspx?id=" + serviceId); } if (e.CommandName == "favourite") { if (string.IsNullOrEmpty(LblUid.Text)) { Session["error"] = "Please log in to favourite a service"; Response.Redirect("~/Views/auth/login.aspx"); } string serviceId = e.CommandArgument.ToString(); List <BL.service.Service> service = new BL.service.Service().SelectById(serviceId); BL.service.Service curr = new BL.service.Service(); User curruser = getCurrUser(); User freelancer = new User().SelectById(service[0].uid.ToString()); List <string> userfavs = new Fav().SelectUserFavs(LblUid.Text); if (!userfavs.Contains(serviceId)) { int servres = curr.Favourite(serviceId, service[0].favs + 1); Fav fav = new Fav(int.Parse(LblUid.Text), int.Parse(serviceId)); int favres = fav.Add(); if (favres == 1 && servres == 1) { Notification notif = new Notification(int.Parse(LblUid.Text), curruser.username, service[0].Id, service[0].name, freelancer.Id.ToString(), "fav"); notif.AddNotif(); Toast.success(this, "Service favourited"); } else { Toast.error(this, "An error occured while favouriting the service"); } } else { int servres = curr.Favourite(serviceId, service[0].favs - 1); Fav fav = new Fav(); int favres = fav.Remove(int.Parse(LblUid.Text), int.Parse(serviceId)); if (favres == 1 && servres == 1) { Toast.success(this, "Service unfavourited"); } else { Toast.error(this, "An error occured while unfavouriting the service"); } } List <string> userFavs = new Fav().SelectUserFavs(LblUid.Text); List <BL.service.Service> servFavs = new List <BL.service.Service>(); foreach (string favs in userFavs) { List <BL.service.Service> serv = new BL.service.Service().SelectById(favs); servFavs.Add(serv[0]); } favList.DataSource = servFavs; favList.DataBind(); } }
protected void managelist_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "viewprofile") { Response.Redirect("~/Views/profile/index.aspx"); } if (e.CommandName == "edit") { Response.Redirect("~/Views/service/edit.aspx?id=" + e.CommandArgument.ToString()); } if (e.CommandName == "delete") { int result = new BL.service.Service().Delete(e.CommandArgument.ToString()); if (result == 1) { Toast.success(this, "Service deleted successfully"); } else { Toast.error(this, "An error occured while deleting service"); } List <BL.service.Service> services = new BL.service.Service().SelectByUid(LblUid.Text); managelist.DataSource = services; managelist.DataBind(); } if (e.CommandName == "view") { Response.Redirect("~/Views/service/index.aspx?id=" + e.CommandArgument.ToString()); } if (e.CommandName == "favourite") { string serviceId = e.CommandArgument.ToString(); List <BL.service.Service> service = new BL.service.Service().SelectById(serviceId); BL.service.Service curr = new BL.service.Service(); List <string> userfavs = new Fav().SelectUserFavs(LblUid.Text); if (!userfavs.Contains(serviceId)) { int servres = curr.Favourite(serviceId, service[0].favs + 1); Fav fav = new Fav(int.Parse(LblUid.Text), int.Parse(serviceId)); int favres = fav.Add(); if (favres == 1 && servres == 1) { Toast.success(this, "Service favourited"); } else { Toast.error(this, "An error occured while favouriting the service"); } } else { int servres = curr.Favourite(serviceId, service[0].favs - 1); Fav fav = new Fav(); int favres = fav.Remove(int.Parse(LblUid.Text), int.Parse(serviceId)); if (favres == 1 && servres == 1) { Toast.success(this, "Service unfavourited"); } else { Toast.error(this, "An error occured while unfavouriting the service"); } } List <BL.service.Service> services = new BL.service.Service().SelectByUid(LblUid.Text); managelist.DataSource = services; managelist.DataBind(); } }
public void Create(Fav entity) { _favRepository.Create(entity); }
void Awake() { instance = this; }