public async Task <IActionResult> Create([Bind("Key,Title,UserKey,Content,Date")] Complains complains) { if (ModelState.IsValid) { complains.Date = DateTime.Now; complains.UserKey = 5; _context.Add(complains); var complainStatus = new ComplainsStatus(complains.Key); _context.Add(complainStatus); await _context.SaveChangesAsync(); return(Redirect("/Home/Index")); } ViewData["UserKey"] = new SelectList(_context.Users, "Key", "City", complains.UserKey); return(View(complains)); }
public async Task <IActionResult> Create([Bind("Key,Type")] Department department) { if (ModelState.IsValid) { _context.Add(department); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(department)); }
public async Task <IActionResult> BuyFlight([Bind("Key,OwnerId")] PlainTickets plainTickets) { if (ModelState.IsValid) { // Add to history // TODO: replace t with current user TicketsHistory ticketsHistory = new TicketsHistory(5, plainTickets.OwnerId, plainTickets.Key); _context.Add(ticketsHistory); // Remove from plain tickets var a = _context.PlainTickets.First(x => x.Key == plainTickets.Key); a.IsSold = true; await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create([Bind("Key,ComplainKey,Status,Comments")] ComplainsStatus complainsStatus) { if (ModelState.IsValid) { _context.Add(complainsStatus); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ComplainKey"] = new SelectList(_context.Complains, "Key", "Content", complainsStatus.ComplainKey); return(View(complainsStatus)); }
public async Task <IActionResult> Create([Bind("Key,KeySeller,KeyBuyer,KeyTicket,DateOfTrade")] TicketsHistory ticketsHistory) { if (ModelState.IsValid) { _context.Add(ticketsHistory); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["KeyBuyer"] = new SelectList(_context.Users, "Key", "City", ticketsHistory.KeyBuyer); ViewData["KeySeller"] = new SelectList(_context.Users, "Key", "City", ticketsHistory.KeySeller); ViewData["KeyTicket"] = new SelectList(_context.PlainTickets, "Key", "FlightNumber", ticketsHistory.KeyTicket); return(View(ticketsHistory)); }