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)));
            }
        }
コード例 #2
0
        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)));
        }
コード例 #3
0
        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
            }));
        }
コード例 #5
0
        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 }));
        }
コード例 #6
0
        public async Task AddClassAsync(Class newClass)
        {
            await _context.AddAsync(newClass);

            await _context.SaveChangesAsync();
        }