public ActionResult MarsRoverImages(string dt) { DateTime.TryParse(dt, out DateTime dtt); Models.Photos pDefault = new Models.Photos { photos = new List <Models.photos> { new Models.photos { id = 1, img_src = "" } } }; if (dtt == System.DateTime.MinValue) { return(View(pDefault)); } using (HttpClient client = new HttpClient { BaseAddress = new Uri(System.Configuration.ConfigurationManager.AppSettings["API_BaseURL"]) }) { var dataPhotos = client.GetAsync($"Nasa/MarsPhotos/Date/{dtt.Year}-{dtt.Month}-{dtt.Day}").Result.Content.ReadAsStringAsync().Result; var d = Newtonsoft.Json.JsonConvert.DeserializeObject <Models.Photos>(dataPhotos); //TempData["NewPhotos"] = d; //RedirectToAction("ShowUpdatedListBox", d); //return View(d); //return View(d); return(Json(d)); //return new JsonResult() { Data = d}; } }
public ActionResult Index() { Models.Photos pDefault = new Models.Photos { photos = new List <Models.photos> { new Models.photos { id = 1, img_src = "" } } }; return(View("MarsRoverImages", pDefault)); //return View(); }
public long?CreateItem(string PersonGuid, long DeviceId, Models.Photos item) { if (PersonGuid != string.Empty && PersonGuid != null) { return((long)db.CreatePersonPhoto(Guid.Parse(PersonGuid), item.Photo).FirstOrDefault()); } else if (DeviceId > 0) { return((long)db.CreateDevicePhoto(DeviceId, item.Photo).FirstOrDefault()); } return(null); }
public ActionResult ShowUpdatedListBox() { if (TempData["NewPhotos"] == null) { Models.Photos pDefault = new Models.Photos { photos = new List <Models.photos> { new Models.photos { id = 1, img_src = "" } } }; return(View("MarsRoverImages", pDefault)); } return(View("MarsRoverImages", TempData["NewPhotos"])); }
public async Task <IActionResult> AddVenue(IList <IFormFile> files) { Locations loc = new Locations(); loc.city = Request.Form["city"]; loc.province = Request.Form["province"]; loc.country = "Canada"; loc.street = Request.Form["street"]; loc.postal_code = Request.Form["postal_code"]; loc.latitude = "45"; loc.longitude = "75"; _context.Locations.Add(loc); _context.SaveChanges(); short locId = loc.id; Venues venue = new Venues(); venue.name = Request.Form["name"]; venue.guest_capacity = Convert.ToInt16(Request.Form["guest_capacity"]); venue.venue_size_sqf = Convert.ToDouble(Request.Form["venue_size_sqf"]); venue.price_hourly = Convert.ToDecimal(Request.Form["price_hourly"]); venue.price_daily = Convert.ToDecimal(Request.Form["price_daily"]); venue.fk_location = locId; venue.fk_Vendor = (short)HttpContext.Session.GetInt32("vendorId"); _context.Venues.Add(venue); _context.SaveChanges(); short venueId = venue.id; /*Code for each of the filter types*/ /*Venue Types*/ IList <Venue_Types_Venues> newVenueTypes = new List <Venue_Types_Venues>(); var venueTypesIds = Request.Form["venueTypes"].ToList(); foreach (String item in venueTypesIds) { newVenueTypes.Add(new Venue_Types_Venues() { fk_Venue = venueId, fk_Venue_Type = Convert.ToInt16(item) }); } _context.Venue_Types_Venues.AddRange(newVenueTypes); //do i need to save changes from here on out? since these don't rely on each other? // _context.SaveChanges(); /*Venue Rules*/ IList <Venue_Rules_Venues> newVenueRules = new List <Venue_Rules_Venues>(); var venueRulesIds = Request.Form["venueRules"].ToList(); foreach (String item in venueRulesIds) { newVenueRules.Add(new Venue_Rules_Venues() { fk_Venue = venueId, fk_Venue_Rule = Convert.ToInt16(item) }); } _context.Venue_Rules_Venues.AddRange(newVenueRules); // _context.SaveChanges(); /*Amenities*/ IList <Amenities_Venues> newAmenities = new List <Amenities_Venues>(); var amenitiesIds = Request.Form["amenities"].ToList(); foreach (String item in amenitiesIds) { newAmenities.Add(new Amenities_Venues() { fk_Venue = venueId, fk_Amenity = Convert.ToInt16(item) }); } _context.Amenities_Venues.AddRange(newAmenities); // _context.SaveChanges(); /*Event Types*/ IList <Event_Types_Venues> newEventTypes = new List <Event_Types_Venues>(); var eventTypesIds = Request.Form["eventTypes"].ToList(); foreach (String item in eventTypesIds) { newEventTypes.Add(new Event_Types_Venues() { fk_Venue = venueId, fk_Event_Type = Convert.ToInt16(item) }); } _context.Event_Types_Venues.AddRange(newEventTypes); //do i need to save changes from here on out? since these don't rely on each other? // _context.SaveChanges(); /*On Site Services*/ IList <On_Site_Services_Venues> newOnSiteServicesTypes = new List <On_Site_Services_Venues>(); var onSiteServicesTypesIds = Request.Form["onSiteServices"].ToList(); foreach (String item in onSiteServicesTypesIds) { newOnSiteServicesTypes.Add(new On_Site_Services_Venues() { fk_Venue = venueId, fk_On_Site_Service = Convert.ToInt16(item) }); } _context.On_Site_Services_Venues.AddRange(newOnSiteServicesTypes); //do i need to save changes from here on out? since these don't rely on each other? // _context.SaveChanges(); /*Style Venues*/ IList <Styles_Venues> newStylesTypes = new List <Styles_Venues>(); var stylesTypes = Request.Form["venueStyles"].ToList(); foreach (String item in stylesTypes) { newStylesTypes.Add(new Styles_Venues() { fk_Venue = venueId, fk_Style = Convert.ToInt16(item) }); } _context.Styles_Venues.AddRange(newStylesTypes); //do i need to save changes from here on out? since these don't rely on each other? // _context.SaveChanges(); /*Features Venues*/ IList <Features_Venues> newFeatures = new List <Features_Venues>(); var featuresTypes = Request.Form["features"].ToList(); foreach (String item in featuresTypes) { newFeatures.Add(new Features_Venues() { fk_Venue = venueId, fk_Feature = Convert.ToInt16(item) }); } _context.Features_Venues.AddRange(newFeatures); //do i need to save changes from here on out? since these don't rely on each other? _context.SaveChanges(); //testing stuff var uploads = Path.Combine(_hostingEnvironment.WebRootPath, "Images"); foreach (var file in files) { if (file.Length > 0) { Photos photo = new Models.Photos(); photo.filename = file.FileName; var filePath = Path.Combine(uploads, file.FileName); /*This next line has to change when we decide how to store images in a filesystem*/ var dbFilePath = "~/Images/" + file.FileName; photo.url = dbFilePath; photo.fk_Venue = venueId; _context.Photos.Add(photo); _context.SaveChanges(); using (var fileStream = new FileStream(filePath, FileMode.Create)) { await file.CopyToAsync(fileStream); } } } return(RedirectToAction("Index")); }
public long DeleteItem(Models.Photos item) { var result = db.DeletePhoto(item.ID); return(item.ID); }
public long UpdateItem(Models.Photos item) { var result = db.UpdatePhoto(item.ID, item.Photo, item.IsActive); return(item.ID); }