public void PopulatePageAndSubmit() { FirstName.SendKeys("Miller"); LastName.SendKeys("John"); UserEmail.SendKeys("*****@*****.**"); Gender.Click(); MobileNumber.SendKeys("0751123456"); DateOfBirth.Click(); Month.Click(); Year.Click(); Day.Click(); Subjects.SendKeys("Test subjects"); Thread.Sleep(2000); Hobbies.Click(); ((IJavaScriptExecutor)_driver).ExecuteScript("arguments[0].scrollIntoView(true);", Picture); //Thread.Sleep(5000); //Picture.Click(); CurrentAddress.SendKeys("Str. 13 Dec"); Thread.Sleep(2000); StateDropDown.Click(); StateOption.Click(); CityDropDown.Click(); CityOption.Click(); Submit.Click(); }
public void HobbiesConstructorTest() { string initValue = "secret test string"; Hobbies target = new Hobbies(initValue); Assert.AreEqual(target.Value, initValue, "Object value should be identical after construction"); }
public IActionResult CreateHobby(Hobbies Hob) { int?MUser_Id = HttpContext.Session.GetInt32("User_Id"); if (MUser_Id == null) { return(RedirectToAction("Index")); } int User_Id = (int)MUser_Id; if (ModelState.IsValid) { List <Hobbies> hobbies = dbContext.Hobbies.ToList(); foreach (Hobbies hobby in hobbies) { if (hobby.Name == Hob.Name) { ModelState.AddModelError("Name", "Hobby name already exists"); return(View("AddHobby")); } } dbContext.Add(Hob); dbContext.SaveChanges(); return(RedirectToAction("Hobbies")); } else { return(View("AddHobby")); } }
static void Main(string[] args) { var house = new House(); house.NumFloors = 2; house.NumRooms = 5; house.YearBuilt = 1987; Console.WriteLine(house); var car = new Car(); car.ModelYear = 2015; car.Make = "Toyota"; car.Model = "Corolla"; car.Doors = 4; car.Miles = 23333; Console.WriteLine(car); var hobbies = new Hobbies(); hobbies.Hobby1 = "Photography"; hobbies.Hobby2 = "Wildlife watching"; hobbies.Hobby3 = "Planespotting"; hobbies.Hobby4 = "Singing"; hobbies.Hobby5 = "World travel"; Console.WriteLine($"My hobbies are: {hobbies.Hobby1}, {hobbies.Hobby2}, {hobbies.Hobby3}, {hobbies.Hobby4} and {hobbies.Hobby5}."); }
private void AddHobby(int p_index, string p_hobby) { Hobbies.Add(p_index, new SimpleResumeElement { Description = p_hobby }); }
public ActionResult DeleteConfirmed(int id) { Hobbies hobbies = db.Hobbiest.Find(id); db.Hobbiest.Remove(hobbies); db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult Update(int hId, Hobbies d) { Hobbies hobby = _context.Hobbies.FirstOrDefault(h => h.HobbyId == hId); hobby.Title = d.Title; hobby.Description = d.Description; _context.SaveChanges(); return(Redirect($"/hobby/{hId}")); }
public ActionResult Edit([Bind(Include = "ID,NAME,DESCRIPTION")] Hobbies hobbies) { if (ModelState.IsValid) { db.Entry(hobbies).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hobbies)); }
public ActionResult Edit(Hobbies hobbies) { if (ModelState.IsValid) { db.Entry(hobbies).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hobbies)); }
public bool Equals(Person person) { return(FirstName.Equals(person.FirstName) && LastName.Equals(person.LastName) && Address.Equals(person.Address) && DateOfBirth.Equals(person.DateOfBirth) && Hobbies.Equals(person.Hobbies) && Gender.Equals(person.Gender) && Image.Equals(person.Image)); }
public ActionResult Edit([Bind(Include = "Student_Id,Hobbies_List")] Hobbies hobbies) { if (ModelState.IsValid) { db.Entry(hobbies).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hobbies)); }
public ActionResult Create([Bind(Include = "ID,NAME,DESCRIPTION")] Hobbies hobbies) { if (ModelState.IsValid) { db.Hobbies.Add(hobbies); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hobbies)); }
public ActionResult Create(Hobbies hobbies) { if (ModelState.IsValid) { db.Hobbies.Add(hobbies); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hobbies)); }
public void AddNewHobby(Hobby hobby) { if (Hobbies.Count < maxHobbyCount) { Hobbies.Add(hobby); } else { Console.WriteLine($"Can not add {hobby.Text}. Person has too many hobbies"); } }
public ActionResult Create([Bind(Include = "Student_Id,Hobbies_List")] Hobbies hobbies) { if (ModelState.IsValid) { db.Hobbiest.Add(hobbies); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hobbies)); }
public void TrackHobbies(int time, User user) { Console.WriteLine("Please enter a name of your hobby: "); var hobbyName = Console.ReadLine(); var hobby = new Hobbies() { Name = hobbyName, SessionTime = time }; user.AllHobbbies.Add(hobby); }
public void RemoveSelectedHobby(int hobbyId, string removalReason) { for (int i = 0; i < Hobbies.Count; i++) { if (Hobbies[i].HobbyId == hobbyId) { HobbiesLog.Add($"removed \"{Hobbies[i].Text}\", reason - {removalReason}"); Hobbies.RemoveAt(i); return; } Console.WriteLine($"Error removing hobbie. Hobby with Id {hobbyId} not found"); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { string[] cities = { "Киев", "Чернигов", "Харьков", "Львов", "Полтава", "Сумы", "Одесса" }; string[] hobbies = { "Туризм", "Музыка", "Футбол", "Рисование", "Кино", "Танцы" }; Cities.DataSource = cities; Cities.DataBind(); Cities.Items.Insert(0, ""); Hobbies.DataSource = hobbies; Hobbies.DataBind(); } }
private void DisplayHobbies() { Hobbies hb = new Hobbies(); DataSet DS = hb.LoadHobbies(); foreach (DataRow Dr in DS.Tables[0].Rows) { CheckBox ObjCheckbox = new CheckBox(); ObjCheckbox.ID = Dr["HobbyID"].ToString(); ObjCheckbox.Text = Dr["HobbyName"].ToString(); Panel1.Controls.Add(ObjCheckbox); } }
private void InitHobbies(ResumeData p_resume) { ResumeDataHobbies v_home = (ResumeDataHobbies)p_resume.Items[2]; for (int i = 0; i < v_home.Hobbie.Length; i++) { ResumeDataHobbiesHobbie v_adr = (ResumeDataHobbiesHobbie)v_home.Hobbie.GetValue(i); int v_index = Convert.ToInt16(v_adr.index); Hobbies.Add(v_index, new SimpleResumeElement { Description = v_adr.Value.ToString().Replace("\\n", Environment.NewLine) }); } }
// GET: Hobbies/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Hobbies hobbies = db.Hobbiest.Find(id); if (hobbies == null) { return(HttpNotFound()); } return(View(hobbies)); }
protected void BtnInsert_Click(object sender, EventArgs e) { try{ Customer newcustomer = new Customer(); newcustomer.CustomerName = TxtCustName.Text; newcustomer.CountryCode = Convert.ToInt16(DdlCountry.SelectedItem.Value); if (RadioMale.Checked) { newcustomer.Gender = "Male"; } else { newcustomer.Gender = "Female"; } if (RadioMarried.Checked) { newcustomer.Ismarried = true; } else { newcustomer.Ismarried = false; } newcustomer.saveCustomer(); foreach (object obj in Panel1.Controls) { if (obj is CheckBox) { CheckBox oCheckbox = (CheckBox)obj; // if checkboxes are checked if (oCheckbox.Checked) { Hobbies objHob = new Hobbies(); objHob.InsertHobby(newcustomer.CustomerId, Convert.ToInt16(oCheckbox.ID)); // insert } } } } //else // Response.Write("There was a problem in adding data... please try after some time"); catch (Exception ex) { Response.Write("This customer already available"); } Cleardata(); }
public IActionResult HobbyDescription(int Hobby_Id) { int?MUser_Id = HttpContext.Session.GetInt32("User_Id"); if (MUser_Id == null) { return(RedirectToAction("Index")); } int User_Id = (int)MUser_Id; Hobbies Hobby = dbContext.Hobbies .Include(h => h.HobbiesInUsers) .ThenInclude(u => u.User) .FirstOrDefault(r => r.HobbyId == Hobby_Id); return(View("HobbyDescription", Hobby)); }
public async Task <IActionResult> CreateHobby(Hobbies model) { try { if (ModelState.IsValid) { context.Add(model); await context.SaveChangesAsync(); return(RedirectToAction("index", "LoggedIn")); } } catch (DbException ex) { ModelState.AddModelError(ex.ToString(), "Unable to save changes. Please contact a system admin"); } return(RedirectToAction("index", "LoggedIn", model)); }
public virtual void ReadXml(XmlReader r) { r.ReadStartElement(); _name = r.ReadElementContentAsString("name", ""); _position = (EmployeePosition)Enum.Parse(typeof(EmployeePosition), r.ReadElementContentAsString("position", "")); _capacity = r.ReadElementContentAsFloat("capacity", ""); if (r.Name == "Hobbies") { while (r.NodeType == XmlNodeType.Element) { if (r.Name == "Hobbies") { Hobbies.Add(r.ReadElementContentAsString("hobby", "")); } } } r.ReadEndElement(); }
public IActionResult CreateEnthusiast(int Hobby_Id, string Proficiency) { int?MUser_Id = HttpContext.Session.GetInt32("User_Id"); if (MUser_Id == null) { return(RedirectToAction("Index")); } int User_Id = (int)MUser_Id; Hobbies hobby = dbContext.Hobbies .Include(h => h.HobbiesInUsers) .ThenInclude(v => v.User) .FirstOrDefault(u => u.HobbyId == Hobby_Id); foreach (HIU h in hobby.HobbiesInUsers) { System.Console.WriteLine("__________"); System.Console.WriteLine("session Id: " + User_Id); System.Console.WriteLine("hobby user id:" + h.UserId); if (h.UserId == User_Id) { return(View("HobbyDescription", hobby)); } } User user = dbContext.Users .Include(h => h.UsersInHobbies) .ThenInclude(v => v.Hobby) .FirstOrDefault(u => u.UserId == User_Id); HIU H = new HIU(); H.User = user; H.Hobby = hobby; H.Proficiency = Proficiency; dbContext.Add(H); dbContext.SaveChanges(); return(RedirectToAction("Hobbies")); }
public IActionResult AddHobby(Hobbies hobby) { if (ModelState.IsValid) { if (_context.Hobbies.FirstOrDefault(usr => usr.Title == hobby.Title) != null) { ModelState.AddModelError("Title", "That hobby already exists go join the others or try a different hobby!"); return(View("NewHobby")); } hobby.UserId = (int)HttpContext.Session.GetInt32("userId"); HttpContext.Session.SetInt32("hobbyId", hobby.HobbyId); _context.Add(hobby); _context.SaveChanges(); return(Redirect("Hobby")); } else { return(View("NewHobby")); } }
protected void btnSave_Click(object sender, EventArgs e) { Profile.FirstName = txtName.Text; Profile.Street = txtStreet.Text; Profile.City = txtCity.Text; Profile.State = txtState.Text; Profile.Email = txtEmail.Text; Profile.Phone = txtPhone.Text; Profile.Zip = txtZip.Text; Hobbies hobby = new Hobbies(); hobby.Sport = txtSport.Text; hobby.VideoGame = txtGame.Text; hobby.Collection = txtCollection.Text; hobby.Job = txtJob.Text; Profile.hobby = hobby; Profile.Save(); Response.Redirect("ViewProfile.aspx"); }
public IHttpActionResult GetUser(int userId) { try { using (ReactNativeSampleEntities db = new ReactNativeSampleEntities()) { var user = db.Users.Find(userId); var userHobbies = db.UserHobbiesMappings.Where(x => x.UserId == userId).ToList(); UserModel userModel = new UserModel(); userModel.Country = user.Country1.Name; userModel.CountryId = user.Country; userModel.FirstName = user.FirstName; userModel.LastName = user.LastName; userModel.Email = user.Email; userModel.DOB = user.DOB; userModel.Gender = user.Gender; List <Hobbies> hobbies = new List <Hobbies>(); for (int i = 0; i < userHobbies.Count(); i++) { Hobbies hobby = new Hobbies(); hobby.value = Convert.ToInt32(userHobbies[i].HobbyId); hobby.label = userHobbies[i].Hobby.Hobby1; hobbies.Add(hobby); } userModel.Hobbies = hobbies; return(Content(HttpStatusCode.OK, new { userModel })); } } catch (Exception ex) { return(Content(HttpStatusCode.InternalServerError, "An error occured, please try again later")); } }
public async Task <IActionResult> EditHobby(Guid id, Hobbies model) { if (id != model.HobbieID) { return(NotFound()); } if (ModelState.IsValid) { try { context.Update(model); await context.SaveChangesAsync(); return(RedirectToAction("Index", "LoggedIn")); } catch (DbUpdateException ex) { ModelState.AddModelError(ex.ToString(), "Unable to edit changes. Please contact a system admin"); } } return(RedirectToAction("Index", "LoggedIn", model)); }