public async Task <IActionResult> PutAutomobile(int id, Automobile automobile)
        {
            if (id != automobile.Id)
            {
                return(BadRequest());
            }

            _context.Entry(automobile).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AutomobileExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #2
0
        public async Task <IActionResult> PutCar(int id, Car car)
        {
            if (id != car.Id)
            {
                return(BadRequest());
            }

            _context.Entry(car).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CarExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutBodyType(int id, BodyType bodyType)
        {
            if (id != bodyType.Id)
            {
                return(BadRequest());
            }

            if (ModelState.IsValid)
            {
                _context.Entry(bodyType).State = EntityState.Modified;

                try
                {
                    await _context.SaveChangesAsync();
                }

                catch (DbUpdateConcurrencyException)
                {
                    if (!BodyTypeExists(id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            return(NoContent());
        }
Exemple #4
0
 public ActionResult Edit([Bind(Include = "Id,OwnerId,Vin,Model,Make,Year")] Vehicle vehicle)
 {
     if (ModelState.IsValid)
     {
         db.Entry(vehicle).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(vehicle));
 }
 public ActionResult Edit([Bind(Include = "CarTypeId,Name")] CarType carType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(carType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(carType));
 }
Exemple #6
0
 public void Add(Car car)
 {
     //_car.Add(car);
     using (CarsContext context = new CarsContext())
     {
         var addedEntity = context.Entry(car);
         addedEntity.State = EntityState.Added;
         context.SaveChanges();
     }
 }
Exemple #7
0
 public ActionResult Edit([Bind(Include = "Id,Name,State,City")] Owner owner)
 {
     if (ModelState.IsValid)
     {
         db.Entry(owner).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(owner));
 }
Exemple #8
0
 public void Delete(Car car)
 {
     //_car.Remove(_car.FirstOrDefault(x => x.Id == car.Id));
     using (CarsContext context = new CarsContext())
     {
         var deletedEntity = context.Entry(car);
         deletedEntity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Exemple #9
0
 public static void Update <TEntity>(TEntity entity) where TEntity : class
 {
     using (CarsContext context = new CarsContext())
     {
         DbSet <TEntity> dbset = context.Set <TEntity>();
         context.Entry(entity).State = EntityState.Modified;
         context.Database.Log        = Console.WriteLine;
         context.SaveChanges();
     }
 }
Exemple #10
0
 public ActionResult Edit([Bind(Include = "PointId,Name")] Point point)
 {
     if (ModelState.IsValid)
     {
         db.Entry(point).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(point));
 }
Exemple #11
0
        public async Task <ActionResult> Edit([Bind(Include = "id,date,CarModel,price,mileage,tel,seller,description")] Cars cars) // TODO: check if correct (previously was "model")
        {
            if (ModelState.IsValid)
            {
                db.Entry(cars).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(cars));
        }
Exemple #12
0
 public ActionResult Edit([Bind(Include = "CarId,Name,CarTypeId,Consumption")] Car car)
 {
     if (ModelState.IsValid)
     {
         db.Entry(car).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CarTypeId = new SelectList(db.CarTypes, "CarTypeId", "Name", car.CarTypeId);
     return(View(car));
 }
 public ActionResult Edit(Car car)
 {
     if (ModelState.IsValid)
     {
         db.Entry(car).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.BrandId = new SelectList(db.Brands, "BrandId", "Name", car.BrandId);
     return(View(car));
 }
 public ActionResult Edit([Bind(Include = "TravelId,Name,DirectionId,CarId,TravelDate")] Travel travel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(travel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CarId       = new SelectList(db.Cars, "CarId", "Name", travel.CarId);
     ViewBag.DirectionId = new SelectList(db.Directions, "DirectionId", "Name", travel.DirectionId);
     return(View(travel));
 }
 public ActionResult Edit([Bind(Include = "DirectionId,Name,DepartureId,DestinationId,Distance")] Direction direction)
 {
     if (ModelState.IsValid)
     {
         db.Entry(direction).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DepartureId   = new SelectList(db.Points, "PointId", "Name", direction.DepartureId);
     ViewBag.DestinationId = new SelectList(db.Points, "PointId", "Name", direction.DestinationId);
     return(View(direction));
 }
Exemple #16
0
        public void Update(Car car)
        {
            //Car carToUpdate = _car.FirstOrDefault(x => x.Id == car.Id);
            //carToUpdate.ModelYear = car.ModelYear;
            //carToUpdate.Price = car.ModelYear;
            //carToUpdate.Description = car.Description;
            //carToUpdate.ColorId = car.ColorId;
            //carToUpdate.BrandId = car.BrandId;

            using (CarsContext context = new CarsContext())
            {
                var updatedEntity = context.Entry(car);
                updatedEntity.State = EntityState.Modified;
                context.SaveChanges();
            }
        }
Exemple #17
0
 public async Task <bool> UpdateCar(Car car)
 {
     _carsContext.Entry(await _carsContext.Cars.FirstOrDefaultAsync(x => x.Id == car.Id)).CurrentValues.SetValues(car);
     return(await _carsContext.SaveChangesAsync().ConfigureAwait(false) > 0);
 }
Exemple #18
0
 public void Update(Car car)
 {
     db.Entry(car).State = EntityState.Modified;
 }
Exemple #19
0
 public void Update(Contract contract)
 {
     context.Entry(contract).State = EntityState.Modified;
 }
Exemple #20
0
 public void Update(Client client)
 {
     context.Entry(client).State = EntityState.Modified;
 }