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());
        }
Example #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());
        }
Example #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));
 }
Example #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();
     }
 }
Example #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));
 }
Example #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();
     }
 }
Example #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();
     }
 }
Example #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));
 }
Example #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));
        }
Example #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));
 }
Example #14
0
 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));
 }
Example #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();
            }
        }
Example #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);
 }
Example #18
0
 public void Update(Car car)
 {
     db.Entry(car).State = EntityState.Modified;
 }
Example #19
0
 public void Update(Contract contract)
 {
     context.Entry(contract).State = EntityState.Modified;
 }
Example #20
0
 public void Update(Client client)
 {
     context.Entry(client).State = EntityState.Modified;
 }