public ActionResult Edit([Bind(Include = "ID,CarNumber,Kilometer,IsProper,IsAvailable,CarTypeID,StoreID")] Car car) { if (ModelState.IsValid) { //Car editedCar = db.Cars.Find(car.ID); //editedCar = car; db.Entry(car).State = EntityState.Modified; db.SaveChanges(); return(View("Purchase")); } ViewBag.CarTypeID = new SelectList(db.CarTypes, "CarTypeID", "ModelName", car.CarTypeID); ViewBag.StoreID = new SelectList(db.stores, "StoreID", "StoreName", car.StoreID); return(View(car)); }
public async Task <IActionResult> PutCustomer(int id, Customer customer) { if (id != customer.CustomerId) { return(BadRequest()); } _context.Entry(customer).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutBike(int id, Bike bike) { if (id != bike.BikeId) { return(BadRequest()); } _context.Entry(bike).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BikeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit([Bind(Include = "Id,NazwaUrządzenia,MiesięcznyKosztWypożyczenia")] Urządzenie urządzenie) { if (ModelState.IsValid) { db.Entry(urządzenie).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(urządzenie)); }
public ActionResult Edit([Bind(Include = "Id,Name,Surname,Password,Email,RoleId")] User user) { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RoleId = new SelectList(db.Roles, "Id", "RoleName", user.RoleId); return(View(user)); }
public ActionResult Edit([Bind(Include = "ZamówienieId,Imie,Nazwisko,Ulica,NumerDomu,NumerMieszkania,KosztZamówienia,IlośćMiesięcyWypożyczenia,DataZłożenia,DataZwrotu,UrządzenieId")] Zamówienie zamówienie) { if (ModelState.IsValid) { db.Entry(zamówienie).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UrządzenieId = new SelectList(db.Urządzenia, "UrządzenieId", "NazwaUrządzenia", zamówienie.UrządzenieId); return(View(zamówienie)); }
public ActionResult Edit([Bind(Include = "Id,Brand,Model,Year,Image,OldImage,DailyPrice,VehicleTypeId")] VehicleDto input) { if (ModelState.IsValid) { string newfoto = null; if (input.Image != null && input.Image.ContentLength > 0) { FileInfo fotoinfo = new FileInfo(input.Image.FileName); newfoto = Guid.NewGuid().ToString() + fotoinfo.Extension; string path = Path.Combine(Server.MapPath("~/Upload"), Path.GetFileName(newfoto)); input.Image.SaveAs(path); } var vehicle = db.Vehicles.Include(y => y.VehicleType).FirstOrDefault(x => x.Id == input.Id); if (vehicle == null) { Create(input); } else { vehicle.Brand = input.Brand; vehicle.DailyPrice = input.DailyPrice; vehicle.Image = newfoto != null ? ("/Upload/" + newfoto) : input.OldImage; vehicle.Model = input.Model; vehicle.VehicleTypeId = input.VehicleTypeId; vehicle.Year = input.Year; } db.Vehicles.Add(vehicle); db.Entry(vehicle).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.VehicleTypeId = new SelectList(db.VehicleTypes, "Id", "Type", input.VehicleTypeId); return(View(input)); }