public ActionResult Visit_Facebook() { string[][] friendsInfo = new string[20][]; for (int i = 0; i < 20; i++) { friendsInfo[i] = new string[2]; } string[] myInfo = new string[10]; int fCount = 0; if (facebookConnect(ref friendsInfo, ref myInfo, ref fCount)) { OLX_Context cont = new OLX_Context(); var Femail = myInfo[2]; User u = cont.Users.SingleOrDefault(x => x.Email == Femail); if (u == null) { //0:Name 1:ID 2:Email User newUser = new User(); newUser.Name = myInfo[0]; newUser.FB_ID = myInfo[1]; newUser.Email = myInfo[2]; newUser.Password = "******"; cont.Users.Add(newUser); cont.SaveChanges(); Session["Email"] = newUser.Email; Session["FB_Friends"] = friendsInfo; Session["fCount"] = fCount; return(RedirectToAction("User_Facebook")); } else { if (u.FB_ID == "X") { u.FB_ID = myInfo[1]; cont.SaveChanges(); } Session["Email"] = u.Email; Session["FB_Friends"] = friendsInfo; Session["fCount"] = fCount; return(RedirectToAction("User_Facebook")); } } return(null); }
public ActionResult Send_Email(string Toemail, FormCollection form) { try { OLX_Context cont = new OLX_Context(); Message m = new Message(); m.MessageBody = form["Message_Body"]; m.From = form["Sender_Email"]; m.To = Toemail; cont.Messages.Add(m); cont.SaveChanges(); var api = new MandrillApi("UfOYDeGFVADrZwuEoVdg3g"); var message = new Mandrill.Messages.Message(); message.Subject = "Dummy OLX Message"; message.Text = form["Message_Body"]; message.Text += "\nFROM: "; message.Text += form["Sender_Email"]; message.FromEmail = "*****@*****.**"; message.FromName = "HaZa_OLX"; message.To = new[] { new Mandrill.Messages.Recipient(Toemail, "test") }; api.Send(message); Response.Write("Email Sent"); } catch (Exception ex) { Response.Write("Could not send the e-mail - error: " + ex.Message); } return(null); }
public ActionResult SignUp(FormCollection form) { User u = new User(); TryUpdateModel(u); string email = u.Email; OLX_Context cont = new OLX_Context(); User u1 = cont.Users.SingleOrDefault(x => x.Email == email); if (u1 != null) { ViewBag.Error = "Email already Exists!!!"; return(View()); } if (ModelState.IsValid) { u.FB_ID = "X"; cont.Users.Add(u); cont.SaveChanges(); } //JavaScriptResult jr=JavaScript("Alert.render('Hello');"); return(RedirectToAction("Login")); }
public ActionResult Change_Email(FormCollection form) { OLX_Context cont = new OLX_Context(); string email = Session["Email"].ToString(); User u = cont.Users.Single(x => x.Email == email); u.Email = form["Email"]; Session["Email"] = u.Email; cont.SaveChanges(); return(RedirectToAction("User_Settings")); }
public ActionResult Rate_User(string UserEmail, int ID, FormCollection form) { OLX_Context cont = new OLX_Context(); Rating r = cont.Ratings.Find(UserEmail); int rating = Convert.ToInt32(form["Rating_Value"]); r.Total += rating; r.RatedBy++; cont.SaveChanges(); return(RedirectToAction("AD_Details", new { id = ID, done = true })); }
public ActionResult Change_Contact_Details(FormCollection form) { OLX_Context cont = new OLX_Context(); string email = Session["Email"].ToString(); User u = cont.Users.Single(x => x.Email == email); u.Location = form["Location"]; if (form["Name"] != "") { u.Name = form["Name"]; } if (form["Phone"] != "") { u.Phone = form["Phone"]; } cont.SaveChanges(); return(RedirectToAction("User_Settings")); }
public ActionResult Submit_Ad_Post(FormCollection form, HttpPostedFileBase photo1, HttpPostedFileBase photo2, HttpPostedFileBase photo3) { OLX_Context cont = new OLX_Context(); AD ad = new AD(); TryUpdateModel(ad); if (form["Category"] == "1") { ad.Category = "Car"; ad.Param1 = form["Car_Brand"]; ad.Param2 = form["Mileage"]; } else if (form["Category"] == "2") { ad.Category = "Fashion"; ad.Param1 = form["Fashion_Categories"]; ad.Param2 = form["Gender_Categories"]; } else if (form["Category"] == "3") { ad.Category = "Furniture"; ad.Param1 = form["Furniture_Categories"]; } else if (form["Category"] == "4") { ad.Category = "House"; ad.Param1 = form["Rooms"]; ad.Param2 = form["Area"]; } else if (form["Category"] == "5") { ad.Category = "Mobile"; ad.Param1 = form["Mobile_Brand"]; } if (ModelState.IsValid) { cont.ADS.Add(ad); if (cont.Ratings.Find(form["Email"]) == null) { Rating r = new Rating(); r.Email = form["Email"]; r.RatedBy = 0; r.Total = 0; cont.Ratings.Add(r); } cont.SaveChanges(); string path; Image img = new Image(); path = @"D:\Dropbox\Dropbox\OK\Web_Finale3\Images\"; if (photo1 != null) { photo1.SaveAs(path + photo1.FileName); path = @"\Images\"; img.Path = path + photo1.FileName; img.AD_ID = ad.ID; cont.Images.Add(img); } cont.SaveChanges(); path = @"D:\Dropbox\Dropbox\OK\Web_Finale3\Images\"; if (photo2 != null) { photo2.SaveAs(path + photo2.FileName); path = @"\Images\"; img.Path = path + photo2.FileName; img.AD_ID = ad.ID; cont.Images.Add(img); } cont.SaveChanges(); path = @"D:\Dropbox\Dropbox\OK\Web_Finale3\Images\"; if (photo3 != null) { photo3.SaveAs(path + photo3.FileName); path = @"\Images\"; img.Path = path + photo3.FileName; img.AD_ID = ad.ID; cont.Images.Add(img); } cont.SaveChanges(); } return(RedirectToAction("Home")); }