Beispiel #1
0
        public async Task <IActionResult> Edit(string id, [Bind("TypeId,TypeName,Description")] Models.Type @type)
        {
            if (id != @type.TypeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(@type);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TypeExists(@type.TypeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(@type));
        }
        public async Task <IActionResult> Edit(int id, [Bind("PriceId,BusId,TypeId,Cost")] Price price)
        {
            if (id != price.PriceId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(price);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PriceExists(price.PriceId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                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));
        }
        public async Task <IActionResult> Edit(int id, [Bind("BusId,Name,Age")] Buses buses)
        {
            if (id != buses.BusId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(buses);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BusesExists(buses.BusId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(buses));
        }
 public void Update(TEntity entity)
 {
     _context.Update(entity);
     _context.SaveChanges();
 }