public ActionResult <Class> PostSchoolTrip(SchoolTrip schoolTrip) { _unitOfWork.SchoolTripRepository.Add(schoolTrip); _unitOfWork.SaveChanges(); return(CreatedAtAction("GetSchoolTripById", new { id = schoolTrip.Id }, schoolTrip)); }
public IActionResult DeleteConfirmed(int id) { SchoolTrip schoolTrip = _context.SchoolTrips.Single(m => m.SchoolTripID == id); _context.SchoolTrips.Remove(schoolTrip); _context.SaveChanges(); return(Redirect("/Admin/Index")); }
public async Task <SchoolTrip> PostSchoolTrip(SchoolTrip schoolTrip) { UriBuilder builder = new UriBuilder(ApiConstants.BaseApiUrl) { Path = ApiConstants.BaseApiUriPart + ApiConstants.PostSchoolTripEndpoint }; return(await _genericRepository.PostAsync(builder.ToString(), schoolTrip)); }
// END CUT HERE // BEGIN CUT HERE public static void Main() { try { SchoolTrip ___test = new SchoolTrip(); ___test.run_test(-1); } catch (Exception e) { //Console.WriteLine(e.StackTrace); Console.WriteLine(e.ToString()); } }
public IActionResult Edit(SchoolTrip schoolTrip) { if (ModelState.IsValid) { _context.Update(schoolTrip); _context.SaveChanges(); return(Redirect("/Admin/Index")); } return(View(schoolTrip)); }
// END CUT HERE // BEGIN CUT HERE public static void Main() { try { SchoolTrip ___test = new SchoolTrip(); ___test.run_test(-1); } catch(Exception e) { //Console.WriteLine(e.StackTrace); Console.WriteLine(e.ToString()); } }
public async Task <SchoolTrip> UpdateSchoolTrip(long id, SchoolTrip schoolTrip) { schoolTrip.Teacher = null; UriBuilder builder = new UriBuilder(ApiConstants.BaseApiUrl) { Path = ApiConstants.BaseApiUriPart + ApiConstants.PutSchoolTripEndpoint + id }; return(await _genericRepository.PutAsync(builder.ToString(), schoolTrip)); }
// GET: SchoolTrips/Edit/5 public IActionResult Edit(int?id) { if (id == null) { return(HttpNotFound()); } SchoolTrip schoolTrip = _context.SchoolTrips.Single(m => m.SchoolTripID == id); if (schoolTrip == null) { return(HttpNotFound()); } return(View(schoolTrip)); }
public async Task <SchoolTrip> GetSchoolTripByIdAsync(long id) { SchoolTrip schoolTripFromCache = await GetFromCache <SchoolTrip>(CacheNameConstants.SchoolTripById + id); if (schoolTripFromCache != null) { return(schoolTripFromCache); } UriBuilder builder = new UriBuilder(ApiConstants.BaseApiUrl) { Path = ApiConstants.BaseApiUriPart + ApiConstants.GetSchoolTripByIdEndpoint + id, }; var schoolTrip = await _genericRepository.GetAsync <SchoolTrip>(builder.ToString()); await Cache.InsertObject(CacheNameConstants.SchoolTripById + id, schoolTrip, DateTimeOffset.Now.AddSeconds(20)); return(schoolTrip); }
public IActionResult PutSchoolTrip(long id, SchoolTrip schoolTrip) { if (id != schoolTrip.Id) { return(BadRequest()); } if (!_unitOfWork.SchoolTripRepository.SchoolTripExists(id)) { return(NotFound()); } try { _unitOfWork.SchoolTripRepository.Update(schoolTrip); _unitOfWork.SaveChanges(); } catch (Exception exception) { return(BadRequest(exception.Message)); } return(NoContent()); }
public void Update(SchoolTrip updatedSchoolTrip) { _context.SchoolTrips.Update(updatedSchoolTrip); }
public void Add(SchoolTrip schoolTrip) { _context.SchoolTrips.Add(schoolTrip); }
public IActionResult PlanYourVisit(ShoppingCartViewModel shoppingCart) { ApplicationUser user = null; var viewModel = new ShoppingCartViewModel { Price = _context.Prices.Single(), Event = _context.Events.ToList(), User = user, OrderDetail = shoppingCart.OrderDetail }; if (User.IsInRole("user")) { user = _userManager.FindByNameAsync(User.Identity.Name).Result; } if (shoppingCart.OrderDetail != null) { _context.OrderDetails.Add(shoppingCart.OrderDetail); } if (shoppingCart.BirthDayParty != null) { BirthdayParty bp = shoppingCart.BirthDayParty; bp.IsAdminAccepted = "N/A"; _context.BirthdayParties.Add(bp); viewModel = new ShoppingCartViewModel { Event = _context.Events.ToList(), User = user, }; ViewData["birthday"] = "true"; } if (shoppingCart.SchoolTrip != null) { SchoolTrip st = shoppingCart.SchoolTrip; st.IsAdminAccepted = "N/A"; _context.SchoolTrips.Add(st); viewModel = new ShoppingCartViewModel { Event = _context.Events.ToList(), User = user, }; ViewData["schooltrip"] = "true"; } if (shoppingCart.SleepOver != null) { SleepOver so = shoppingCart.SleepOver; so.IsAdminAccepted = "N/A"; _context.SleepOvers.Add(so); viewModel = new ShoppingCartViewModel { Event = _context.Events.ToList(), User = user, }; ViewData["sleepover"] = "true"; } if (shoppingCart.OrderDetail != null) { ViewData["orderplaced"] = "true"; viewModel = new ShoppingCartViewModel { Price = _context.Prices.Single(), Event = _context.Events.ToList(), User = user, OrderDetail = shoppingCart.OrderDetail }; } _context.SaveChanges(); return(View(viewModel)); }