public ActionResult login(u_login login) { if (ModelState.IsValid) { using (BSEntities8 dc = new BSEntities8()) { var v = dc.users.Where(a => a.e_mail.Equals(login.Email) && a.password.Equals(login.Password)).FirstOrDefault(); if (login.Email == "*****@*****.**" && login.Password == "ahmed") { a = true; Session["log"] = "3"; return(Redirect("/Regester/Admin")); } else if (v != null) { Session["LogedUserID"] = v.user_id; Session["LogedUserFullname"] = v.name.ToString(); Session["Email"] = login.Email.ToString(); TempData["Name"] = Session["LogedUserFullname"]; TempData["Email"] = Session["Email"]; return(RedirectToAction("AfterLogin")); } else { ModelState.AddModelError("", "The user login or password provided is incorrect.If you are not the memeber then please register your self by clicking the create accoun"); } } } return(View(login)); }
public ActionResult Register(user register) { if (ModelState.IsValid) { using (BSEntities8 dc = new BSEntities8()) { var v = dc.users.Where(a => a.e_mail.Equals(register.e_mail)).FirstOrDefault(); if (v != null) { ModelState.AddModelError("", "This Email is already register please try again with another email"); Redirect("Regester/Register"); } if (v == null) { user Data = new user(); Data.name = register.name; Data.e_mail = register.e_mail; Data.password = register.password; Data.cpass = register.cpass; dc.users.Add(Data); dc.SaveChanges(); ModelState.Clear(); register = null; ViewBag.Message = "Successfully Registration Done"; } } } return(View(register)); }
public ActionResult Create(ad ad) { ///////// Module for not Posting the add again and again//////////////// /*if (ModelState.IsValid) * { * * * using (BSEntities8 da = new BSEntities8()) * { * * var ab = da.ads.Where(a => a.catagory.Equals(ad.catagory) && a.description.Equals(ad.description) && a.title.Equals(ad.title)).FirstOrDefault(); * * if (ab != null) * { * // ModelState.AddModelError("", "The Ad You have entered is already submitted thanks for anticipation"); * * Session["error"] = "The Ad Youhave submitted is already On Paksell thanks for the Anticipation"; * Redirect("ad/create"); * * * * } * * * } * * } * * */ var Data = db.ads.Add(ad); Data.ad_id = ad.ad_id; Data.area_id = ad.area_id; Data.catagory = ad.catagory; Data.cityId = ad.cityId; Data.date = System.DateTime.Now; Data.description = ad.description; Data.title = ad.title; Data.phone = ad.phone; Data.e_mail = Session["Email"].ToString(); Data.user_id = (int)Session["LogedUserID"]; Data.name = Session["LogedUserFullname"].ToString(); int i = 0; foreach (string file in Request.Files) { HttpPostedFileBase hpf = Request.Files[file] as HttpPostedFileBase; if (hpf.ContentLength == 0) { continue; } string saveFileName = Path.GetFileName(hpf.FileName); string location = Path.Combine(Server.MapPath("~/Images/" + @"\" + saveFileName)); Request.Files[file].SaveAs(location); if (i >= 2) { i = 0; } // Count + 1 each time i++; if (i == 1) { Data.url1 = saveFileName; } else if (i == 2) { Data.url3 = saveFileName; } } if (ModelState.IsValid) { db.ads.Add(ad); db.SaveChanges(); using (BSEntities8 dc = new BSEntities8()) { if (dc.Iusers != null) { foreach (var v in dc.Iusers) { var s = dc.Iusers.Where(a => a.Scat.Equals(Data.catagory) && a.Sitem.Equals(Data.title)).FirstOrDefault(); { if (s != null) { string cat = s.Scat; string item = s.Sitem; string phone = Data.phone.ToString(); string message = "Your intrested item posted cat is " + cat + "and item is:" + item + "and the cell number is" + phone; var twilio = new TwilioRestClient("ACfb4f763d08b8e11d5f5937fc052a6464", "c97a3b969fd6fe2bdc8f83fa61f3f465"); var call = twilio.InitiateOutboundCall("+1555456790", "+15551112222", "http://example.com/handleCall"); var msg = twilio.SendMessage("+14843027060", "+923237575485", message); } } } } } return(RedirectToAction("/AfterLogin")); } ViewBag.area_id = new SelectList(db.areas, "area_id", "name", ad.area_id); ViewBag.user_id = new SelectList(db.users, "user_id", "name", ad.user_id); ViewBag.cityId = new SelectList(db.cities, "cityId", "CityName", ad.cityId); return(View()); }