public ActionResult AddBuilding(int id, int row, int column) { //validate int currentUserID = Int32.Parse(Request.Cookies["currentUser"]["id"]); var userOwnsCity = (from C in entities.user_cities where C.city_id == id && C.user_id == currentUserID select C).Count(); if (userOwnsCity == 0) { //ERROR PAGE return(RedirectToAction("Error", "Account")); } // napunimo model za korisnika user currentUser = (from e in entities.users where e.id == currentUserID select e).First(); UserDetailsModel userDetails = new UserDetailsModel(); userDetails.fillUserDetailsModel(currentUser, entities); /* napunimo addBuilding model, koji sadrzi detalje korisnika, * id grada u kojem pravimo zgradu, * i sve zgrade koje mogu da se prave*/ AddBuildingModel addBuildingModel = new AddBuildingModel(); addBuildingModel.fillAddBuildingModel(userDetails, id, row, column, entities); return(View(addBuildingModel)); }
public ActionResult ShowCity(int id) { // ako nismo ulogovani, prebacuje nas na login if (!Request.Cookies.AllKeys.Contains("currentUser")) { return(RedirectToAction("LogIn", "Account")); } //validacija user-a int currentUserID = Int32.Parse(Request.Cookies["currentUser"]["id"]); var userOwnsCity = (from C in entites.user_cities where C.city_id == id && C.user_id == currentUserID select C).Count(); if (userOwnsCity == 0) { //ERROR PAGE return(RedirectToAction("Error", "Account")); } // napunimo model za grad CityDetailsModel cityDetails = new CityDetailsModel(); var currentCity = (from C in entites.cities where C.id == id select C).First(); cityDetails.fillCityDetailsModel(currentCity, entites); // napunimo model za korisnika user currentUser = (from e in entites.users where e.id == currentUserID select e).First(); UserDetailsModel userDetails = new UserDetailsModel(); userDetails.fillUserDetailsModel(currentUser, entites); // showcity model napunimo ovim modelima ShowCityModel showCityModel = new ShowCityModel(); showCityModel.fillShowCityModel(userDetails, cityDetails); return(View(showCityModel)); }
public ActionResult Index() { int currentUserID; if (!Request.Cookies.AllKeys.Contains("currentUser")) { return(RedirectToAction("LogIn", "Account")); } //var id = Request.Cookies["userID"].Value; currentUserID = Int32.Parse(Request.Cookies["currentUser"]["id"]); user currentUser = (from USER in entites.users where USER.id == currentUserID select USER).First(); UserDetailsModel userDetailsModel = new UserDetailsModel(); userDetailsModel.fillUserDetailsModel(currentUser, entites); return(View(userDetailsModel)); }