//Not in used public static string AddPlace(placeDTO place) { SwapDbConnection db = new SwapDbConnection(); if (db.places.FirstOrDefault(p => p.latitude == place.latitude && p.longitude == place.longitude) != null) { return(null); } place place_obj = new place() { place_id = place.place_id, creation_date = DateTime.Now, latitude = place.latitude, description = place.description, state = place.state, settlement = place.settlement, name = place.name, longitude = place.longitude, country = place.country, street = place.street, street_number = place.street_number, post_code = place.post_code, }; db.places.Add(place_obj); db.SaveChanges(); return(place.place_id); }
public IHttpActionResult Putplace(int id, place place) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != place.id) { return(BadRequest()); } db.Entry(place).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!placeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public JsonResult Index() { string cs = @"server=localhost;userid=root;password=;database=findR"; MySqlConnection conn =null; try { conn = new MySqlConnection(cs); conn.Open(); }catch(MySqlException ex){ Console.WriteLine("error: {0}", ex.ToString()); } string state = "SELECT * FROM findr.locations"; var cmd = new MySqlCommand(state,conn); var reader = cmd.ExecuteReader(); List<place> places = new List<place>(); while (reader.Read()){ var newPlace = new place(); newPlace.lat = reader.GetDouble(0); newPlace.lon = reader.GetDouble(1); newPlace.type = reader.GetString(2); newPlace.name = reader.GetString(3); newPlace.details = reader.GetString(4); newPlace.id = reader.GetInt32(5); places.Add(newPlace); } return Json(places, JsonRequestBehavior.AllowGet); }
private void add_place() { place aux_place = new place(); this.Dialogs.Add(new PlaceDialogViewModel { Title = "Afegir un Espai", SelectedPlace = aux_place, OkText = "Afegir", TextEnabled = true, OnOk = (sender) => { try { context.places.Add(aux_place); context.SaveChanges(); FillEspais(); sender.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }, OnCancel = (sender) => { sender.Close(); }, OnCloseRequest = (sender) => { sender.Close(); } }); }
private void del_place() { place aux_place = SelectedPlace; this.Dialogs.Add(new PlaceDialogViewModel { Title = "Esborrar Espai", SelectedPlace = aux_place, OkText = "Confirmar", TextEnabled = false, OnOk = (sender) => { try { if (aux_place.requests.Count == 0) { context.places.Remove(aux_place); context.SaveChanges(); } else { MessageBox.Show("Aquest Espai té projectes assignats, si us plau, esborra primer els projectes."); } sender.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }, OnCancel = (sender) => { sender.Close(); }, OnCloseRequest = (sender) => { sender.Close(); } }); }
private void mod_place() { place aux_place = SelectedPlace; this.Dialogs.Add(new PlaceDialogViewModel { Title = "Modificar Espai", SelectedPlace = aux_place, OkText = "Modificar", TextEnabled = true, OnOk = (sender) => { try { context.places.Where(x => x.id_place == aux_place.id_place).SingleOrDefault().name = aux_place.name; context.places.Where(x => x.id_place == aux_place.id_place).SingleOrDefault().address = aux_place.address; context.places.Where(x => x.id_place == aux_place.id_place).SingleOrDefault().capacity = aux_place.capacity; context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } sender.Close(); }, OnCancel = (sender) => { sender.Close(); }, OnCloseRequest = (sender) => { sender.Close(); } }); }
public ActionResult DeleteConfirmed(int id) { place place = db.places.Find(id); db.places.Remove(place); db.SaveChanges(); return(RedirectToAction("Index")); }
//Add new event //Input: NewEventDTO //Output: EventDTO static public EventDTO AddEvent(NewEventDTO eventToAdd) { SwapDbConnection db = new SwapDbConnection(); Event myEvent; place place = db.places.FirstOrDefault(p => p.place_id == eventToAdd.place.place_id); if (place != null) { if (place.business != null || place.Event != null) { return(null); } place.name = eventToAdd.place.name; place.description = eventToAdd.place.description; } myEvent = new Event { end_date = eventToAdd.end_date, start_date = eventToAdd.start_date, place_id = eventToAdd.place.place_id, price = eventToAdd.price, place = place ?? new place { place_id = eventToAdd.place.place_id, country = eventToAdd.place.country ?? "", creation_date = DateTime.Now, description = eventToAdd.place.description, name = eventToAdd.place.name, post_code = eventToAdd.place.post_code, settlement = eventToAdd.place.settlement, state = eventToAdd.place.state, street_number = eventToAdd.place.street_number ?? "", street = eventToAdd.place.street, latitude = eventToAdd.place.latitude, longitude = eventToAdd.place.longitude, } }; db.Events.Add(myEvent); db.SaveChanges(); return(new EventDTO { country = myEvent.place.country ?? "", description = myEvent.place.description ?? "", end_date = myEvent.end_date, name = myEvent.place.name ?? "", place_id = myEvent.place_id, post_code = myEvent.place.post_code ?? "", price = myEvent.price, settlement = myEvent.place.settlement ?? "", start_date = myEvent.start_date, state = myEvent.place.state ?? "", street = myEvent.place.street ?? "", street_number = myEvent.place.street_number ?? "" }); }
public ActionResult Edit([Bind(Include = "placeID,name,type,address,city,note,phone,email")] place place) { if (ModelState.IsValid) { db.Entry(place).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(place)); }
public ActionResult Edit([Bind(Include = "id,name,address,dates,fees,map")] place place) { if (ModelState.IsValid) { db.Entry(place).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(place)); }
public void fillProjectes(place p) { List <request> lr = context.requests.Where(x => x.place_id == p.id_place).ToList(); List <project> lp = new List <project>(400); foreach (request r in lr) { lp.Add(r.project); } ProjectsL = new ObservableCollection <project>(lp); }
public ActionResult Create([Bind(Include = "id,name")] place place) { if (ModelState.IsValid) { db.places.Add(place); db.SaveChanges(); return(RedirectToAction("Create")); } return(View(place)); }
public ActionResult Create([Bind(Include = "placeID,name,type,address,city,note,phone,email")] place place) { if (ModelState.IsValid) { db.places.Add(place); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(place)); }
public IHttpActionResult Postplace(place place) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.places.Add(place); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = place.id }, place)); }
//Not in used public static bool Editplace(placeDTO place) { SwapDbConnection db = new SwapDbConnection(); place place_obj = db.places.FirstOrDefault(p => p.place_id == place.place_id); if (place_obj == null) { return(false); } if (place.longitude != 0) { place_obj.longitude = place.longitude; } if (place.latitude != 0) { place_obj.latitude = place.latitude; } if (place.description != null) { place_obj.description = place.description; } if (place.state != null) { place_obj.state = place.state; } if (place.name != null) { place_obj.name = place.name; } if (place.settlement != null) { place_obj.settlement = place.settlement; } if (place.post_code != null) { place_obj.post_code = place.post_code; } if (place.street != null) { place_obj.street = place.street; } if (place.street_number != null) { place_obj.street_number = place.street_number; } if (place.country != null) { place_obj.country = place.country; } db.SaveChanges(); return(true); }
public place[] getRelatedPlacesByPlacetags(place place) { List <place> list = new List <place>(); foreach (tags tag in place.tags) { tags taged = ActiveRecordBase <tags> .Find(tag.id); list.AddRange(taged.places); } place[] places = list.ToArray(); return(places); }
protected virtual void opProject() { place p = SelectedPlace; if (SelectedPlace != null) { this.Dialogs.Add(new ProjectesViewModel(p, context) { context = context, Boto_afegir_enabled = true, }); } }
//Not in used public static bool DeletePlace(string place_id) { SwapDbConnection db = new SwapDbConnection(); place place_obj = db.places.Where(x => x.place_id == place_id).FirstOrDefault(); if (place_obj == null) { return(false); } db.places.Remove(place_obj); db.SaveChanges(); return(true); }
public ActionResult DeleteConfirmed(int id) { place place = db.places.Find(id); db.places.Remove(place); IEnumerable <project> projects = db.projects.Where(p => p.placeID == id); foreach (project p in projects) { p.placeID = null; } db.SaveChanges(); return(RedirectToAction("Index")); }
public IHttpActionResult Deleteplace(int id) { place place = db.places.Find(id); if (place == null) { return(NotFound()); } db.places.Remove(place); db.SaveChanges(); return(Ok(place)); }
// GET: places/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } place place = db.places.Find(id); if (place == null) { return(HttpNotFound()); } return(View(place)); }
public int placeByURL_id(string url) { List <AbstractCriterion> baseEx = new List <AbstractCriterion>(); baseEx.Add(Expression.Eq("CustomUrl", url)); place place = ActiveRecordBase <place> .FindFirst(baseEx.ToArray()); if (place != null) { return(place.id); } else { return(0); } }
public ActionResult Edit(place place) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://52.165.230.106/api/v1.0/"); //HTTP POST var putTask = client.PutAsJsonAsync <place>("Places", place); putTask.Wait(); var result = putTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } } return(View(place)); }
public ActionResult create(place place) { using (var coordinates = new HttpClient()) { coordinates.BaseAddress = new Uri("http://52.165.230.106/api/v1.0/"); //HTTP POST var postTask = coordinates.PostAsJsonAsync <place>("Places", place); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } } ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator."); return(View(place)); }
public ActionResult Edit(int id) { place place = null; using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://52.165.230.106/api/v1.0/"); //HTTP GET var responseTask = client.GetAsync("Places/" + id.ToString()); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <place>(); readTask.Wait(); place = readTask.Result; } } return(View(place)); }
public void SetLocation(place location) { string town, region; // If location type is ZipCode append it to location name if ((location.placeTypeName.Value == "Zip Code" || location.placeTypeName.Value == "Postal Code")) { town = location.name; if (location.locality2 != null && !String.IsNullOrEmpty(location.locality2.Value)) { town += " - " + location.locality2.Value; } else { if (location.locality1 != null && !String.IsNullOrEmpty(location.locality1.Value)) { town += " - " + location.locality1.Value; } } } else { if (location.locality2 != null && !String.IsNullOrEmpty(location.locality2.Value)) { town = location.locality2.Value; } else if (location.locality1 != null && !String.IsNullOrEmpty(location.locality1.Value)) { town = location.locality1.Value; } else { town = location.name; } } // Try to get region name or fallback to country name if (location.admin1 != null && !String.IsNullOrEmpty(location.admin1.Value)) { region = location.admin1.Value; } else if (location.admin2 != null && !String.IsNullOrEmpty(location.admin2.Value)) { region = location.admin2.Value; } else { region = location.country.Value; } LocationName = string.Format("{0}, {1}", town, region); LocationCountry = location.country.code; LocationQuery = location.woeid; LocationLat = (double)location.centroid.latitude; LocationLong = (double)location.centroid.longitude; LocationTZ_Long = location.timezone.Value; }
public LocationQueryViewModel(place location) { SetLocation(location); }
//Add new quest //Input: QuestDTO //Output: void public static void AddNewQuest(QuestDTO quest) { SwapDbConnection db = new SwapDbConnection(); r_place_sub_and_main_category placeCategories; place place; List <place> places; quest newQuest = new quest { client_id = quest.userId, creation_date = DateTime.Now, quest_id = IdService.generateID("quest_id"), places = new List <place>() }; //Update categories of places foreach (GooglePlaceDTO googlePlace in quest.googlePlaces) { place = db.places.FirstOrDefault(p => p.place_id == googlePlace.googlePlace.place_id); if (place != null) { placeCategories = place.r_place_sub_and_main_category.FirstOrDefault(p => p.main_id == googlePlace.main_id && p.sub_id == googlePlace.sub_id); if (placeCategories == null) { place.r_place_sub_and_main_category.Add(new r_place_sub_and_main_category { creation_date = DateTime.Now, main_id = googlePlace.main_id, place_id = googlePlace.googlePlace.place_id, sub_id = googlePlace.sub_id }); } } //Add new place to db else { place = new place { latitude = googlePlace.googlePlace.latitude, place_id = googlePlace.googlePlace.place_id, longitude = googlePlace.googlePlace.longitude, country = googlePlace.googlePlace.country, creation_date = DateTime.Now, description = googlePlace.googlePlace.description, name = googlePlace.googlePlace.name, post_code = googlePlace.googlePlace.post_code, settlement = googlePlace.googlePlace.settlement, state = googlePlace.googlePlace.state, street = googlePlace.googlePlace.street, street_number = googlePlace.googlePlace.street_number, r_place_sub_and_main_category = new List <r_place_sub_and_main_category> { new r_place_sub_and_main_category { creation_date = DateTime.Now, place_id = googlePlace.googlePlace.place_id, main_id = googlePlace.main_id, sub_id = googlePlace.sub_id } } }; db.places.Add(place); } newQuest.places.Add(place); } places = db.places.Where(p => quest.eventsIds.Contains(p.place_id) || quest.businessesIds.Contains(p.place_id)).ToList(); newQuest.places = newQuest.places.Concat(places).ToList(); db.quests.Add(newQuest); db.SaveChanges(); }
public ActionResult Create(/*[Bind(Include = "id,name,address,dates,fees,map,map_image,logo_image")]*/ place place) { if (ModelState.IsValid) { string filename = Path.GetFileNameWithoutExtension(place.map_image.FileName); string extention = Path.GetExtension(place.map_image.FileName); filename = filename + DateTime.Now.ToString("yymmddssfff") + extention; place.map = "~/Content/images/map/" + filename; filename = Path.Combine(Server.MapPath("~/Content/images/map/"), filename); place.map_image.SaveAs(filename); db.places.Add(place); db.SaveChanges(); var new_imageLogo = new place_images(); new_imageLogo.place_id = db.places.OrderByDescending(x => x.id).FirstOrDefault().id; string filename2 = Path.GetFileNameWithoutExtension(place.logo_image.FileName); string extention2 = Path.GetExtension(place.logo_image.FileName); filename2 = filename2 + DateTime.Now.ToString("yymmddssfff") + extention2; new_imageLogo.image = "~/Content/images/places/" + filename2; filename2 = Path.Combine(Server.MapPath("~/Content/images/places/"), filename2); place.logo_image.SaveAs(filename2); new_imageLogo.altr = "Logo Image"; db.place_images.Add(new_imageLogo); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(place)); }
public ProjectesViewModel(place p, triaculturaDBEntities ctx) { context = ctx; titol = "Projectes"; fillProjectes(p); }
=> GenerateContract(entity, association, place, groups.Select(g => (g.Item1, g.Item2, new List <Shooter>())).ToList(), stages);