public ActionResult Index() { using (DataClasses1DataContext c = new DataClasses1DataContext()) { var m = new MainIndexModel(); /*ViewBag.menu = (from tt in c.menu select new SelectListItem() { Value = tt.Id.ToString(), Text = tt.name_pizza }).ToList();*/ return View(m); } }
public ActionResult Edit(int id, MainIndexModel model) { if (Request["Submit"] != null) { using (DataClasses1DataContext ctx = new DataClasses1DataContext()) { main t = (from tt in ctx.main where tt.Id == id select tt).First(); t.id_pizza = model.Id_pizza; ctx.SubmitChanges(); } } return(RedirectToAction("Index", "Home")); }
public ActionResult Index(MainIndexModel model) { if (Request["Submit"] != null) { using (DataClasses1DataContext ctx = new DataClasses1DataContext()) { customer t = new customer() { name = model.Name_Customer, surname = model.Surname_Customer, }; ctx.customer.InsertOnSubmit(t); ctx.SubmitChanges(); } } return RedirectToAction("Index", "Home"); }
public ActionResult AddOrder(MainIndexModel model) { if (Request["Submit"] != null) { using (DataClasses1DataContext ctx = new DataClasses1DataContext()) { main t = new main() { id_pizza = model.Id_pizza, id_customer = model.Id_customer, date = DateTime.Now }; ctx.main.InsertOnSubmit(t); ctx.SubmitChanges(); } } return(RedirectToAction("Index", "Home")); }
public ActionResult AddOrder() { using (DataClasses1DataContext c = new DataClasses1DataContext()) { var m = new MainIndexModel(); ViewBag.customer = (from ttt in c.customer select new SelectListItem() { Value = ttt.Id.ToString(), Text = ttt.name + " " + ttt.surname }).ToList(); ViewBag.menu = (from tt in c.menu select new SelectListItem() { Value = tt.Id.ToString(), Text = tt.name_pizza }).ToList(); return(View("AddOrder", m)); } }
public async Task <IActionResult> Index(int artistId, MainIndexModel srch) { var url = "https://localhost:44334/api/SearchRest/searchArtistsByGenres?"; // put in appSettings //var url = "https://wikivox.azurewebsites.net/api/SearchRest/searchArtistsByGenres?"; // put in appSettings var terms = string.Empty; if (srch.GenreListing == null) { // default genre search terms = "term=1"; } else { //loop thru list and obtain search terms foreach (var g in srch.GenreListing) { if (g.isMarked) { if (terms == string.Empty) { terms += "term=" + g.Id; } else { terms += "&term=" + g.Id; } } } } List <Artist> artistModel = new List <Artist>(); using (var httpClient = new HttpClient()) { using (var response = await httpClient.GetAsync(url + terms)) { string apiResponse = await response.Content.ReadAsStringAsync(); artistModel = JsonConvert.DeserializeObject <List <Artist> >(apiResponse); } } // by default, load one artist in object for launch page Random rnd = new Random(); int artistNum = _artist.GetAll().Count(); //var x = x - 1; int defaultArtistId = rnd.Next(1, artistNum - 1); var artistInfoModel = _artist.Get(defaultArtistId); // if an artist has been selected, gather details to display if (artistId != 0) { artistInfoModel = _artist.Get(artistId); } var genreModel = _genre.GetAll(); var artistGenreModel = _artistGenre.GetAll(); // genre list var genres = genreModel.Select (g => new GenreListingModel { Id = g.Id, Name = g.Name } ).ToList(); // artist list var artists = artistModel.Select (a => new ArtistListingModel { Id = a.Id, ArtistName = a.ArtistName } ).ToList(); var artistGenres = artistGenreModel.Select (r => new ArtistGenreModel { Id = r.Id, Artist = r.Artist, Genre = r.Genre } ).ToList(); var artistInfo = new ArtistListingModel { Id = artistInfoModel.Id, ArtistName = artistInfoModel.ArtistName, Bio = artistInfoModel.Bio, YrFormed = artistInfoModel.YrFormed, YrEnded = artistInfoModel.YrEnded, isActive = artistInfoModel.isActive, HomeCountry = artistInfoModel.HomeCountry, HomeTown = artistInfoModel.HomeTown, PrimaryImage = _image.GetPrimaryImageByEntity(2, artistInfoModel.Id, 1) }; var model = new MainIndexModel { GenreListing = genres, ArtistListing = artists, ArtistGenre = artistGenres, ArtistInfo = artistInfo }; return(View(model)); }