public async Task <IActionResult> Create([Bind("Id,LastName,FirstName,SurName,BirthDay,Address")] Tourist tourist) { if (ModelState.IsValid) { _context.Add(tourist); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tourist)); }
public async Task <IActionResult> Create([Bind("Id,CountryName,InfoVisa")] Country country) { if (ModelState.IsValid) { _context.Add(country); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(country)); }
public async Task <IActionResult> Create([Bind("Id,LastName,FirstName,SurName,Email")] Manager manager) { if (ModelState.IsValid) { _context.Add(manager); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(manager)); }
public async Task <IActionResult> Create(int cityId, [Bind("Id,HotelName,Stars,RoomType,CityId")] Hotel hotel) { hotel.CityId = cityId; if (ModelState.IsValid) { _context.Add(hotel); await _context.SaveChangesAsync(); //return RedirectToAction(nameof(Index)); return(RedirectToAction("Index", "Hotels", new { id = cityId, name = _context.Cities.Where(c => c.Id == cityId).FirstOrDefault().CityName })); } // ViewData["CountryId"] = new SelectList(_context.Countries, "Id", "CountryName", city.CountryId); //return View(city); return(RedirectToAction("Index", "Hotels", new { id = cityId, name = _context.Cities.Where(c => c.Id == cityId).FirstOrDefault().CityName })); }
public async Task <IActionResult> Create(int hotelId, [Bind("Id,TourName,TourDuration,ManagerId,HotelId")] Tour tour) { tour.HotelId = hotelId; if (ModelState.IsValid) { _context.Add(tour); // tour.Manager = _context.Managers.Find(tour.ManagerId); // tour.Hotel = _context.Hotels.Find(tour.HotelId); await _context.SaveChangesAsync(); //return RedirectToAction(nameof(Index)); return(RedirectToAction("Index", "Tours", new { id = hotelId, name = _context.Hotels.Where(c => c.Id == hotelId).FirstOrDefault().HotelName })); } // ViewData["CountryId"] = new SelectList(_context.Countries, "Id", "CountryName", city.CountryId); //return View(city); return(RedirectToAction("Index", "Tours", new { id = hotelId, name = _context.Hotels.Where(c => c.Id == hotelId).FirstOrDefault().HotelName })); }
public async Task <IActionResult> Create(int tourId, [Bind("Id,TourId,TouristId,Price,BuyDate,StartDate")] Voucher voucher) { voucher.TourId = tourId; if (ModelState.IsValid) { _context.Add(voucher); // tour.Manager = _context.Managers.Find(tour.ManagerId); // tour.Hotel = _context.Hotels.Find(tour.HotelId); await _context.SaveChangesAsync(); //return RedirectToAction(nameof(Index)); return(RedirectToAction("Index", "Vouchers", new { id = tourId, name = _context.Tours.Where(c => c.Id == tourId).FirstOrDefault().TourName })); } // ViewData["CountryId"] = new SelectList(_context.Countries, "Id", "CountryName", city.CountryId); //return View(city); return(RedirectToAction("Index", "Vouchers", new { id = tourId, name = _context.Tours.Where(c => c.Id == tourId).FirstOrDefault().TourName })); }
public async Task <ActionResult> DeleteInfo(int id) { Information information = await _context.Information.FirstOrDefaultAsync(r => r.Id == id); if (information != null) { _context.Information.Remove(information); await _context.SaveChangesAsync(); } return(RedirectToAction("InformationEdit")); }
public async Task AdminLeave(string name) { using (var context = new TourAgencyContext()) { try { var admin = context.VideoConnects.FirstOrDefault(f => f.Name == name); if (admin == null) { return; } context.VideoConnects.Remove(admin); await context.SaveChangesAsync(); } catch { } } }
public async Task CallEnd(string name) { using (var context = new TourAgencyContext()) { try { var admin = context.VideoConnects.FirstOrDefault(f => f.Name == name); if (admin == null) { return; } admin.IsBusy = false; await context.SaveChangesAsync(); } catch (Exception e) { } } }
public async Task <bool> AddNewAdmin(string name) { using (var context = new TourAgencyContext()) { try { VideoConnect admin = new VideoConnect(); admin.Name = name; admin.IsBusy = false; context.VideoConnects.Add(admin); await context.SaveChangesAsync(); return(true); } catch { return(false); } } }
public async Task <bool> MakeConnect(string name) { using (var context = new TourAgencyContext()) { try { var admin = context.VideoConnects.FirstOrDefault(f => f.Name == name); if (admin == null) { return(false); } admin.IsBusy = true; await context.SaveChangesAsync(); return(true); } catch { return(false); } } }
public async Task <bool> OptionCout(int id) { try { using (var context = new TourAgencyContext()) { SurveyValueModel elm = await context.SurveyValue.FirstOrDefaultAsync(r => r.Id == id); if (elm != null) { elm.OptionCout = ++elm.OptionCout; await context.SaveChangesAsync(); } } return(true); } catch (Exception el) { return(false); } }
public async Task <ActionResult> AddButton(NewsModel model, string action) { long Id = 0; NewsModel elm = null; if (action == "Add") { _context.NewsModel.Add(new NewsModel() { Text = "Пункт", IconUri = "", Language = DataConfig.Language.CodeLang }); } if (action == "Save") { if (model != null) { elm = await _context.NewsModel.FindAsync(model.Id); if (elm != null) { Id = elm.Id; elm.Text = model.Text; elm.ContentType = model.ContentType; } } } if (action == "Delete") { if (model != null) { elm = await _context.NewsModel.FindAsync(model.Id); if (elm != null) { _context.NewsModel.Remove(elm); } } } await _context.SaveChangesAsync(); if (Id == 0) { elm = _context.NewsModel.ToList().LastOrDefault(); if (elm != null) { Id = elm.Id; } } return(RedirectToAction("MenuEditor", "Home", new { @id = Id })); }
public async Task SaveAsync() { await db.SaveChangesAsync(); }