public ActionResult Update(Person personUpdate) { var returnedPerson = PersonDAO.Search(UserSession.ReturnPersonId(null)); if (returnedPerson == null) return RedirectToAction("Logout", "User"); // Get the coordinates of the bar location that the user has given Tuple<double, double> tuple = GoogleGeoLocation.GetCoordinates(personUpdate.Address, personUpdate.City, personUpdate.State); // Set the remaining properties of the model returnedPerson.Lat = tuple.Item1; returnedPerson.Lng = tuple.Item2; returnedPerson.Name = personUpdate.Name; returnedPerson.Birthday = personUpdate.Birthday; returnedPerson.Address = personUpdate.Address; returnedPerson.City = personUpdate.City; returnedPerson.State = personUpdate.State; if (PersonDAO.Update(returnedPerson) != true) { ModelState.AddModelError("", "Error - Check information and try again"); return View("Account"); } return View("Account"); }
public ActionResult Account() { var returnedPerson = PersonDAO.Search(UserSession.ReturnPersonId(null)); if (returnedPerson == null) return RedirectToAction("Logout", "User"); ViewBags(returnedPerson); return View(returnedPerson); }
public ActionResult Dashboard() { var personSession = PersonDAO.Search(UserSession.ReturnPersonId(null)); if (personSession == null) return RedirectToAction("Logout", "User"); ViewBags(personSession); return View(personSession); }
public ActionResult Pubs() { var returnedPerson = PersonDAO.Search(UserSession.ReturnPersonId(null)); if (returnedPerson == null) return RedirectToAction("Logout", "User"); ViewBags(returnedPerson); return View(PubDAO.ReturnList().OrderByDescending(l => l.Rating).ToList()); }
public IHttpActionResult GetPersonById(int personId) { Person person = PersonDAO.Search(personId); if (person == null) { return(NotFound()); } return(Ok(person)); }
public ActionResult Delete(string password) { var returnedPerson = PersonDAO.Search(UserSession.ReturnPersonId(null)); if (returnedPerson == null) return RedirectToAction("Logout", "User"); var returnedUser = UserDAO.Search(returnedPerson.UserId); if (password != returnedUser.Password) { ModelState.AddModelError("", "Error - Password does not match"); return View("Account"); } PersonDAO.Delete(returnedPerson); UserDAO.Delete(returnedUser); return RedirectToAction("Logout", "User"); }
public ActionResult Login(User user) { var pub = PubDAO.Search(user.Email, user.Password); var person = PersonDAO.Search(user.Email, user.Password); if (pub != null) { UserSession.ReturnPubId(pub.Id); return(RedirectToAction("Dashboard", "Pub")); } else if (person != null) { UserSession.ReturnPubId(person.Id); return(RedirectToAction("Dashboard", "Person")); } return(View("Login", user)); }
public ActionResult Pub(int id) { var pub = PubDAO.Search(id); var returnedPerson = PersonDAO.Search(UserSession.ReturnPersonId(null)); if (returnedPerson == null) return RedirectToAction("Logout", "User"); ViewBag.ProductList = ProductDAO.ReturnList(pub.Id); ViewBag.Categories = new MultiSelectList(CategoryDAO.ReturnList(), "Id", "Name"); if (RatingDAO.SearchByPersonAndPubId(UserSession.ReturnPersonId(null), id) != null) { ViewBag.Rate = "Unrate"; } else { ViewBag.Rate = "Rate"; } ViewBags(returnedPerson); return View(pub); }
public ActionResult UpdatePhoto(HttpPostedFileBase upImage) { if (upImage == null) { ModelState.AddModelError("", "Error - Image dont work"); return View("Account"); } var returnedPerson = PersonDAO.Search(UserSession.ReturnPersonId(null)); if (returnedPerson == null) return RedirectToAction("Logout", "User"); returnedPerson.Photo = ImageHandler.HttpPostedFileBaseToByteArray(upImage); returnedPerson.PhotoType = upImage.ContentType; if (PersonDAO.Update(returnedPerson) != true) { ModelState.AddModelError("", "Error - Database update image error!"); return View("Account"); } return RedirectToAction("Account"); }