public async Task <IActionResult> CreateOrder(OrderViewModel model) { // var post = new Post // { // TopicId = model.TopicId, // TimeStamp = model.TimeStamp, // Poster = model.Poster, // Body = model.Body // }; // await _context.AddAsync(post); // await _context.SaveChangesAsync(); // return RedirectToAction(nameof(Index)); var order = new Order() { PickUpAddress = model.PickUpAddress, DropOffAddress = model.DropOffAddress }; await _context.AddAsync(order); await _context.SaveChangesAsync(); if (model.CargoCount != 0) { return(RedirectToAction(nameof(CreateCargo), new { cargocount = model.CargoCount })); } else { return(RedirectToAction(nameof(Index))); } }
public async Task <IActionResult> CreateTopic(TopicViewModel model) { var topic = new Topic { Title = model.Title, OriginalPoster = model.OriginalPoster, PostCount = model.PostCount }; await _context.AddAsync(topic); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create(Student student) { if (student.Id == 0) { await _context.AddAsync(student); } else { _context.Update(student); } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <ActionResult> SaveInputValue(string name) { var test = new Test { Name = name }; await _context.AddAsync(test); await _context.SaveChangesAsync(); return(Json(new { code = 1 })); }
public async Task <IActionResult> AddSudent(Student student) { if (student == null) { return(Unauthorized()); } int?Cls; if (HttpContext.Session.GetInt32("Stage") != null) { if ((Cls = HttpContext.Session.GetInt32("Class")) != null) { student.TimeAbsent = 0; } } await context.AddAsync(student); await context.SaveChangesAsync(); return(Ok(new { isInsert = student.StudentName })); }
public async Task AddClassAsync(Class newClass) { await _context.AddAsync(newClass); await _context.SaveChangesAsync(); }