public async Task <IActionResult> Edit(int id, [Bind("ID,CNP")] UnwantedUser unwantedUser)
        {
            if (id != unwantedUser.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(unwantedUser);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UnwantedUserExists(unwantedUser.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(unwantedUser));
        }
Example #2
0
        public T Update(T itemToUpdate)
        {
            var entity = dbContext.Update <T>(itemToUpdate);

            dbContext.SaveChanges();
            return(entity.Entity);
        }
Example #3
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,RegistrationNumber,Km,ManufacutreDate,Status,Brand,Model,Class,Price")] Car car)
        {
            if (id != car.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(car);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CarExists(car.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(car));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,User,Car,Start,End")] History history)
        {
            if (id != history.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(history);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HistoryExists(history.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(history));
        }