public ActionResult AcceptAgreement(int userID) { UserDetail detail = new UserDetail(); detail.UserId = userID; UserAcceptanceViewModel uacceptvm = new UserAcceptanceViewModel(); uacceptvm.UserId = userID; UserAgreement ua = dbmeals.UserAgreements.Where(x => x.Name == "Seller Agreement").FirstOrDefault(); uacceptvm.UserAgreement = ua.AgreementDetails; uacceptvm.AgreementID = ua.AgreementID; return View(uacceptvm); }
public void UpdateUser(UserDetail user) { dbmeals.Entry(user).State = EntityState.Modified; }
public void InsertUser(UserDetail user) { dbmeals.UserDetails.Add(user); }
public RedirectToRouteResult RedirectPage(int userid) { string ipaddress = Request.ServerVariables["REMOTE_ADDR"]; ipaddress = ipaddress == null ? String.Empty : ipaddress; ipaddress = ipaddress.Replace("\r\n", ","); ipaddress = ipaddress.Replace(" ", ","); ipaddress = ipaddress.Replace(":", ""); string[] arripaddress = ipaddress.Split(','); string location = string.Empty; string address = String.Empty; if (arripaddress.Length != 0) { for (int i = 0; i <= arripaddress.Length - 1; i++) { if (arripaddress[i] != "") { // check if the IP address is supported in demo version long ipno = IP2Decimal(arripaddress[i]); if ((ipno > 0) || (ipno < 33554431)) { SqlDataReader reader; // select MS-SQL database using DSNless connection SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString); // query string to lookup the country by matching the range of IP address number SqlCommand sqlCmd = new SqlCommand("SELECT TOP 1 * FROM ip2location_db3_ipv6 WHERE " + ipno.ToString() + " <= ip_to ORDER BY ip_to", sqlConn); sqlCmd.Connection.Open(); // execute the query reader = sqlCmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection); // display results if (reader.Read()) { location = Convert.ToString(reader["city_name"]); address = Convert.ToString(reader["city_name"]) + "," + Convert.ToString(reader["region_name"]) + "," + Convert.ToString(reader["country_name"]); //Response.Write("<tr>"); //Response.Write("<td align=center>" + arripaddress[i] + "</td>"); //Response.Write("<td align=center>" + reader.GetString(0) + "</td>"); //Response.Write("<td align=center>" + reader.GetString(1) + "</td>"); //Response.Write("</tr>"); } sqlCmd.Connection.Close(); } } } } var user = db.UserProfiles.Where(x => x.UserId.Equals(userid)).First(); Session["FirstName"] = user.FirstName; LocationsSearched ls = new LocationsSearched(); ls = dbmeals.LocationsSearcheds.Where(x => x.UserID.Equals(userid)).OrderByDescending(y => y.DateCreated).FirstOrDefault(); if (ls != null) { Session["UserLoc"] = ls.Location; Session["UserLocLat"] = Convert.ToDouble(ls.Latitude); Session["UserLocLong"] = Convert.ToDouble(ls.Longitude); } else { if (!string.IsNullOrEmpty(location)) { Session["UserLoc"] = location; GLatLong latlng = GetLatLng(address); Session["UserLocLat"] = (decimal)latlng.Latitude; Session["UserLocLong"] = (decimal)latlng.Longitude; } else { return RedirectToAction("LocationToSearch", "Home", null); } } if (Session["UserLoc"] == null) { UserDetail userdetail = new UserDetail(); userdetail = dbmeals.UserDetails.Where(x => x.UserId.Equals(userid)).FirstOrDefault(); if (userdetail != null) { Session["UserLoc"] = Common.GetFullAddress(userdetail.AddressList); Session["UserLocLat"] = Convert.ToDouble(userdetail.AddressList.Latitude); Session["UserLocLong"] = Convert.ToDouble(userdetail.AddressList.Longitude); } else Session["UserLoc"] = null; if (Session["UserLocLat"] == null) return RedirectToAction("LocationToSearch", "Home", null); } SearchParam searchparam = new SearchParam(); return RedirectToAction("Index", "Home", new RouteValueDictionary(searchparam)); }
public RedirectToRouteResult RedirectPage(int userid) { UserDetail userdetail = new UserDetail(); userdetail = dbmeals.UserDetails.Where(x => x.UserId.Equals(userid)).FirstOrDefault(); if (userdetail != null) { { // searchparam.UserLoc.Latitude = Convert.ToDouble(userdetail.AddressList.Latitude); // searchparam.UserLoc.Longitude = Convert.ToDouble(userdetail.AddressList.Longitude); // searchparam.UserID = userdetail.UserId; Session["UserLoc"] = Common.GetFullAddress(userdetail.AddressList); Session["UserLocLat"] = Convert.ToDouble(userdetail.AddressList.Latitude); Session["UserLocLong"] = Convert.ToDouble(userdetail.AddressList.Longitude); if (Session["UserLocLat"] == null) return RedirectToAction("LocationToSearch", "Home", null); else { SearchParam searchparam = new SearchParam(); return RedirectToAction("Index", "Home", new RouteValueDictionary(searchparam)); } } } else { return RedirectToAction("Create", "User", new { userID = userid }); } }
public ActionResult Edit(UserDetail currentinfo, HttpPostedFileBase Photo) { if (ModelState.IsValid) { var fileName = ""; // Verify that the user selected a file if (Photo != null && Photo.ContentLength > 0) { // extract only the fielname fileName = "Profilephoto" + currentinfo.UserId + Path.GetExtension(Photo.FileName); // .GetFileName(Photo.FileName).; // store the file inside ~/App_Data/uploads folder var path = Path.Combine(Server.MapPath("~/ProfilePhotos"), fileName); Photo.SaveAs(path); } if (currentinfo.AddressList != null) { currentinfo.AddressID = currentinfo.AddressList.AddressID; } currentinfo.KitchenTypeID = currentinfo.KitchenTypeID; currentinfo.KitchenName = currentinfo.KitchenName; currentinfo.AddressList.Telephone = currentinfo.AddressList.Telephone; if (!String.IsNullOrEmpty(fileName)) { if (IsImage(Photo)) { }else{ return RedirectToAction("Edit", "User", new { userID = currentinfo.UserId }); } currentinfo.Photo = fileName; } else { string str = userinfo.Photo; currentinfo.Photo = str; } dbmeals.Entry(currentinfo).State = System.Data.EntityState.Modified; dbmeals.SaveChanges(); return RedirectToAction("Details", "User", new { userID = currentinfo.UserId }); } return View(); }
// GET: /UserInfo/Edit/5 public ActionResult Edit(int userid) { userinfo = dbmeals.UserDetails.Find(userid); ViewBag.CountryDDList = dbmeals.LKUPCountries.ToList().Select(x => new SelectListItem { Value = x.CountryID.ToString(), Text = x.Country.ToString(), Selected = (userinfo != null && x.CountryID == userinfo.AddressList.CountryID) }); if (userinfo == null) { return RedirectToAction("Create", "User", new { userID = userid }); } return View(userinfo); }
public ActionResult DeactivateUser(UserDetail currentinfo) { if (ModelState.IsValid) { var userinfo = dbmeals.UserDetails.Find(currentinfo.UserId); userinfo.DateUpdated = DateTime.Now; userinfo.UserStatus = 0; userinfo.Notes = currentinfo.Notes; //dbmeals.Entry(userinfo).State = System.Data.EntityState.Modified; dbmeals.SaveChanges(); return RedirectToAction("Details", "User", new { userID = currentinfo.UserId }); } return View(currentinfo); }