public ActionResult Login(FormCollection fomCollection) { if (fomCollection["Giris"] != null) { var email = fomCollection["Email"]; var pass = fomCollection["Password"]; var sorgu = _context.Users.FirstOrDefault(user => user.Email == email && user.Password == pass); if (sorgu != null) { var name = sorgu.FirstName + " " + sorgu.LastName; Session.Add("ID", sorgu.Id); Session.Add("DisplayName", sorgu.DisplayName); Session.Add("Email", sorgu.Email); Session.Add("Name", name); return(RedirectToAction("Index")); } } else { var email = fomCollection["Email"]; var pass = fomCollection["Password"]; var firstName = fomCollection["FirstName"]; var lastName = fomCollection["LastName"]; var displayName = fomCollection["DisplayName"]; _context.Users.Add(new User() { FirstName = firstName, LastName = lastName, DisplayName = displayName, Email = email, Password = pass, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, isDelete = false }); _context.SaveChanges(); ViewBag.Basarili = "Kayıt Gerçekleşti Şimdi Giriş Yapabilirsiniz"; return(RedirectToAction("Login")); } return(RedirectToAction("Login")); }
public void UpdateCategory(Category category) { using (var context = new FBContext()) { context.Entry(category).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void SaveCategory(Category category) { using (var context = new FBContext()) { context.Categories.Add(category); context.SaveChanges(); } }
public void DeleteCategory(int ID) { using (var context = new FBContext()) { //context.Entry(category).State = System.Data.Entity.EntityState.Deleted; var category = context.Categories.Find(ID); context.Categories.Remove(category); context.SaveChanges(); } }
public ActionResult profileUpdate(FormCollection form) { var SessionUser = Convert.ToInt32(Session["ID"]); var user = _context.Users.Find(SessionUser); _context.Users.AddOrUpdate(new User() { Id = user.Id, DisplayName = form["DisplayName"], FirstName = form["FirstName"], LastName = form["LastName"], Password = form["Password"], Email = form["Email"], }); if (_context.SaveChanges() > 0) { return(RedirectToAction("Index")); } return(null); }
//</inheritdoc> public override void Edit(T entityModel) { try { using (var context = new FBContext()) { context.Entry(entityModel).State = EntityState.Modified; context.SaveChanges(); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
//</inheritdoc> public override void Delete(T model) { try { using (var context = new FBContext()) { var _dbset = context.Set <T>(); _dbset.Attach(model); context.Entry(model).State = EntityState.Deleted; context.SaveChanges(); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
//</inheritdoc> public override void Delete(IdT id) { try { var model = FindById(id); using (var context = new FBContext()) { var _dbset = context.Set <T>(); _dbset.Remove(model); context.SaveChanges(); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public void GroupReview() { var context = new FBContext(); driver = new ChromeDriver(Directory.GetCurrentDirectory(), option); List <User> users = context.Users.Where(u => u.ContactInitiated == false).Take(300).ToList(); foreach (var user in users) { try { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); driver.Url = ConfigurationManager.AppSettings["UserMessage"] + user.FbID; driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); IList <IWebElement> conversation = driver.FindElements(By.CssSelector("div[class='ljqsnud1']"));; StringBuilder conversationText = new StringBuilder(); foreach (var message in conversation) { if (!String.IsNullOrEmpty(message.Text)) { conversationText.Append(message.Text); } } if (conversationText.ToString().Contains("myślę że mogą Ci się przydać te darmowe materiały")) { user.ContactInitiated = true; Console.WriteLine(user.FirstName + user.LastName + " - Contact initiated"); context.SaveChanges(); } } catch (Exception) { Console.WriteLine("Empty conversation"); } } }
public void SendMessage(int FriendId, string FriendDisplayName, string Message, int SessionID) { FBContext _context = new FBContext(); _context.Messages.Add(new Message() { UserId = SessionID, FriendId = FriendId, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, isDelete = false, MessageContent = Message }); if (_context.SaveChanges() > 0) { Clients.Others.GetMessageOther(FriendId, FriendDisplayName, Message); Clients.Caller.GetMessageCaller(Message); } }
//</inheritdoc> public override T Add(T model) { try { using (var context = new FBContext()) { var _dbset = context.Set <T>(); _dbset.AddRange(new List <T>() { model }); context.SaveChanges(); return(model); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); return(null); } }
private static void RegisterReservation(Reservation reservation) { Context.Reservation.Add(reservation); Context.SaveChanges(); }
public void RunAutomation() { driver = new ChromeDriver(Directory.GetCurrentDirectory(), option); driver.Url = ConfigurationManager.AppSettings["GroupPage"]; driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20); IList <IWebElement> allElements = driver.FindElements(By.XPath(".//span")); string value = driver.FindElement(By.XPath(".//span[contains(text(), 'Członkowie: ')]")).Text; value = value.Substring(value.Length - 4, 4); IList <IWebElement> record; listOfUsers = driver.FindElement(By.TagName("div")); record = listOfUsers.FindElements(By.CssSelector("div[data-visualcompletion='ignore-dynamic']")); int numberOfRecords = Convert.ToInt32(value); do { try { IJavaScriptExecutor js = (IJavaScriptExecutor)driver; js.ExecuteScript("window.scrollBy(0,document.body.scrollHeight)"); record = listOfUsers.FindElements(By.TagName("div[data-visualcompletion='ignore-dynamic']")); } catch { //Console.WriteLine("Brak rozszerzonej listy"); } Actions hover = new Actions(driver); IWebElement person = record[index]; hover.MoveToElement(person); hover.Perform(); try { string nameValue = person.FindElement(By.CssSelector("a")).GetAttribute("aria-label"); string idValue = person.FindElement(By.CssSelector("a")).GetAttribute("href"); if (!string.IsNullOrEmpty(nameValue)) { FirstName = nameValue.Substring(0, nameValue.IndexOf(" ")); LastName = nameValue.Substring(nameValue.IndexOf(" ") + 1, (nameValue.Length - FirstName.Length - 1)); Console.WriteLine(index + " " + FirstName + " " + LastName); } if (!string.IsNullOrEmpty(idValue)) { var start = idValue.IndexOf("user") + 5; id = idValue.Substring(start, idValue.Length - start - 1); } if (!string.IsNullOrEmpty(nameValue) && !string.IsNullOrEmpty(idValue)) { using (var context = new FBContext()) { User user = new User(); user.FirstName = FirstName; user.LastName = LastName; user.FbID = id; user.ContactInitiated = false; user.PageLiked = false; user.IsFriend = false; user.SharedInfo = false; if (context.Users.Any(e => e.FbID == id)) { context.Entry(user).State = EntityState.Modified; } else { context.Entry(user).State = EntityState.Added; } context.SaveChanges(); } } } catch (Exception ex) { // Console.WriteLine(ex.ToString()); } index++; } while (index < numberOfRecords); driver.Quit(); }
public void AskForSharing() { var context = new FBContext(); driver = new ChromeDriver(Directory.GetCurrentDirectory(), option); List <User> users = context.Users.Where(u => u.PageLiked == true && u.SharedInfo == false).Take(6).ToList(); foreach (var user in users) { driver.Url = ConfigurationManager.AppSettings["UserMessage"] + user.FbID; driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); string message = "Cześć " + user.FirstName + Environment.NewLine + "dzięki za polubienie strony Szkoły Młodego Programisty. Jeżeli uważasz że to co robię jest" + Environment.NewLine + "wartościowe prośba o udostępnienie by inne osoby mogły skorzystać z publikowanych" + Environment.NewLine + "materiałów." + Environment.NewLine + Environment.NewLine + "Ostatnio odświeżyłem darmowy kurs scratcha i pythona. Fajnie gdyby trafił do dzieci które" + Environment.NewLine + "rozpoczynają przygodę z programowaniem." + Environment.NewLine + Environment.NewLine + "Aby udostępnić wystarczy wejść na stronę " + Environment.NewLine + Environment.NewLine + "https://www.facebook.com/watch/?v=592154964897479" + Environment.NewLine + Environment.NewLine + "I kliknąć 'udostępnij' ze słowem miłego komentarza ;)" + Environment.NewLine + Environment.NewLine + "Jeżeli mogę Ci jakoś pomóc to też proszę daj znać" + Environment.NewLine + Environment.NewLine + "Bardzo dziękuję Ci za wsparcie i zaufanie" + Environment.NewLine + "Pozdrawiam" + Environment.NewLine + "Tomek"; Thread.Sleep(3000); try { string alert = driver.SwitchTo().Alert().Text; driver.SwitchTo().Alert().Accept(); Console.WriteLine(alert); } catch { // Console.WriteLine("Brak alertow"); } IWebElement communication = driver.FindElement(By.CssSelector("div[class='_1mf _1mj']")); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); var clipboard = new Clipboard(); clipboard.SetText(message); communication.SendKeys(Keys.Control + "v"); Thread.Sleep(3000); communication.SendKeys(Keys.Enter); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); user.SharedInfo = true; context.SaveChanges(); Console.WriteLine("Informacja o udostępnianiu wysłana: " + user.FirstName + " " + user.LastName); } driver.Quit(); }
public void GroupPeopleWhoLikePageAnalisys() { IList <IWebElement> listOfUsers; driver = new ChromeDriver(Directory.GetCurrentDirectory(), option); driver.Url = "https://www.facebook.com/szkolamlodegoprogramisty/settings/?tab=people_and_other_pages&ref=page_edit&cquick=jsc_c_l&cquick_token=AQ5ywqAW6TB0YqbF3e8&ctarget=https%3A%2F%2Fwww.facebook.com"; driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); listOfUsers = driver.FindElements(By.TagName("td")); do { try { IJavaScriptExecutor js = (IJavaScriptExecutor)driver; js.ExecuteScript("window.scrollBy(0,document.body.scrollHeight)"); listOfUsers = driver.FindElements(By.TagName("tr")); } catch { //Console.WriteLine("Brak rozszerzonej listy"); } Actions hover = new Actions(driver); IWebElement person = listOfUsers[index]; hover.MoveToElement(person); hover.Perform(); try { string nameValue = person.FindElement(By.CssSelector("a")).Text; string idValue = person.FindElement(By.CssSelector("a")).GetAttribute("href"); if (!string.IsNullOrEmpty(nameValue)) { FirstName = nameValue.Substring(0, nameValue.IndexOf(" ")); LastName = nameValue.Substring(nameValue.IndexOf(" ") + 1, (nameValue.Length - FirstName.Length - 1)); } if (!string.IsNullOrEmpty(idValue)) { var start = idValue.IndexOf(".com/") + 5; id = idValue.Substring(start, idValue.Length - start); } if (!string.IsNullOrEmpty(nameValue) && !string.IsNullOrEmpty(idValue)) { var context = new FBContext(); var current = context.Users.FirstOrDefault(e => e.FbID == id); if (current != null) { current.PageLiked = true; Console.WriteLine("Aktualizacja: " + index + " " + FirstName + " " + LastName); context.SaveChanges(); } else { User user = new User(); user.FirstName = FirstName; user.LastName = LastName; user.FbID = id; user.ContactInitiated = false; user.PageLiked = true; user.IsFriend = false; user.SharedInfo = false; context.Users.Add(user); Console.WriteLine("Dodawanie: " + index + " " + FirstName + " " + LastName); context.SaveChanges(); } } } catch (Exception ex) { // Console.WriteLine(ex.ToString()); } index++; } while (index < 2000); }
public void SendInformation() { var context = new FBContext(); driver = new ChromeDriver(Directory.GetCurrentDirectory(), option); List <User> users = context.Users.Where(u => u.ContactInitiated == false).Take(20).ToList(); foreach (var user in users) { driver.Url = ConfigurationManager.AppSettings["UserMessage"] + user.FbID; driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); string message = "Cześć " + user.FirstName + Environment.NewLine + "myślę że mogą Ci się przydać te darmowe materiały." + Environment.NewLine + Environment.NewLine + "Na stronie" + Environment.NewLine + "https://www.facebook.com/szkolamlodegoprogramisty/" + Environment.NewLine + Environment.NewLine + "przygotowuję DARMOWE ćwiczenia i kursy dla dzieci z programowania do rozwiązywania i " + Environment.NewLine + "przejścia w domu" + Environment.NewLine + Environment.NewLine + "DARMOWY Kurs SCRATCH(6 +)(ponad 1000 osób się zapisało) i PYTHON(9 +)(ponad 800)" + Environment.NewLine + "https://szkolamlodegoprogramisty.pl/kursy/" + Environment.NewLine + Environment.NewLine + "A w między czasie zapraszam na blog" + Environment.NewLine + "https://szkolamlodegoprogramisty.pl/" + Environment.NewLine + Environment.NewLine + "Pozdrawiam" + Environment.NewLine + "Tomek"; Thread.Sleep(5000); try { string alert = driver.SwitchTo().Alert().Text; driver.SwitchTo().Alert().Accept(); Console.WriteLine(alert); } catch { Console.WriteLine("Brak alertow"); } IWebElement communication = driver.FindElement(By.CssSelector("div[class='_1mf _1mj']")); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); var clipboard = new Clipboard(); clipboard.SetText(message); communication.SendKeys(Keys.Control + "v"); Thread.Sleep(5000); communication.SendKeys(Keys.Enter); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); user.ContactInitiated = true; context.SaveChanges(); Console.WriteLine("kontakt nawiazany:" + user.FirstName + " " + user.LastName); } driver.Quit(); }