Exemplo n.º 1
0
        public static void AddRoute(BusContext db, string name)
        {
            var id = new BusRouteId(int.Parse(name));
            var r  = new BusRoute(id, name);

            db.Add(r.State);
            db.SaveChanges();
        }
Exemplo n.º 2
0
        public static void AddBus(BusContext db, string number, string seated, string standing)
        {
            var seatingCapacity  = int.Parse(seated);
            var standingCapacity = int.Parse(standing);

            var id = new BusId(Guid.NewGuid());
            var b  = new Bus(id, number, seatingCapacity, standingCapacity);

            db.Add(b.State);
            db.SaveChanges();
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("TypeId,TypeName,Description")] Models.Type @type)
        {
            if (ModelState.IsValid)
            {
                _context.Add(@type);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(@type));
        }
        public async Task <IActionResult> Create([Bind("BusId,Name,Age")] Buses buses)
        {
            if (ModelState.IsValid)
            {
                _context.Add(buses);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(buses));
        }
        public async Task <IActionResult> Create([Bind("PriceId,BusId,TypeId,Cost")] Price price)
        {
            if (ModelState.IsValid)
            {
                _context.Add(price);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BusId"]  = new SelectList(_context.Buses, "BusId", "BusId", price.BusId);
            ViewData["TypeId"] = new SelectList(_context.Type, "TypeId", "TypeId", price.TypeId);
            return(View(price));
        }
Exemplo n.º 6
0
 public void Create(TEntity entity)
 {
     _context.Add(entity);
     _context.SaveChanges();
 }