public async Task <Collection> GetByIdAsync(int idCollection) { Collection collection = await context.Collections.FindAsync(idCollection); if (collection != null) { await context.Entry(collection) .Collection(x => x.Entries).LoadAsync(); await context.Entry(collection) .Reference(i => i.State).LoadAsync(); } return(collection); }
public async Task <IActionResult> PutTrip(long id, Trips trip) { if (id != trip.Id) { return(BadRequest()); } _context.Entry(trip).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TripExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutEmployee(long id, Employee employee) { if (id != employee.Id) { return(BadRequest()); } _context.Entry(employee).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <Client> > PutClient(int id, Client client) { if (id != client.Id) { return(BadRequest()); } _context.Entry(client).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClientExists(id)) { return(NotFound()); } else { throw; } } return(await _context.Client.FindAsync(client.Id)); }
public ActionResult Edit([Bind(Include = "DepartmentId,Name")] Department department) { if (ModelState.IsValid) { db.Entry(department).State = EntityState.Modified; try { db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { if (ex.InnerException != null && ex.InnerException.InnerException != null && ex.InnerException.InnerException.Message.Contains("_Index")) { ModelState.AddModelError(string.Empty, "The are the record with the same value"); } else { ModelState.AddModelError(string.Empty, ex.Message); } } } return(View(department)); }
public async Task <IActionResult> PutCustomer(long id, Customer customer) { if (id != customer.Id) { return(BadRequest()); } _context.Entry(customer).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IHttpActionResult PutUsers(int id, Users users) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != users.id) { return(BadRequest()); } db.Entry(users).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UsersExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void Put(int id, [FromBody] Review review, string name) { if (review.Name == name) { review.ReviewId = id; _db.Entry(review).State = EntityState.Modified; _db.SaveChanges(); } }
public virtual void Update(T entity) { if (entity == null) { throw new ArgumentNullException("请提供泛型类别"); } db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); }
public ActionResult Edit([Bind(Include = "id,createdAt,updatedAt,version,deleted,idKorisnika,idPutovanja")] RezervisanaPutovanjaAzure rezervisanaPutovanjaAzure) { if (ModelState.IsValid) { db.Entry(rezervisanaPutovanjaAzure).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(rezervisanaPutovanjaAzure)); }
public ActionResult Edit([Bind(Include = "id,createdAt,updatedAt,version,deleted,vrstaKartice,datumIsteka,broj,csc")] KarticaAzure karticaAzure) { if (ModelState.IsValid) { db.Entry(karticaAzure).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(karticaAzure)); }
public ActionResult Edit([Bind(Include = "Id,Name,Age,PassportNo,DateDeparture,DateArrival,FromAirport,ToAirport,Comfort")] Travel travel) { if (ModelState.IsValid) { db.Entry(travel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(travel)); }
public ActionResult Edit([Bind(Include = "TravelTypeID,Name")] TravelType travelType) { if (ModelState.IsValid) { db.Entry(travelType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(travelType)); }
public ActionResult Edit([Bind(Include = "ID,price,startDate,endDate,detail,TravelID")] TravelPlan travelPlan) { if (ModelState.IsValid) { db.Entry(travelPlan).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(travelPlan)); }
public ActionResult Edit([Bind(Include = "ID,name")] Role role) { if (ModelState.IsValid) { db.Entry(role).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(role)); }
public ActionResult Edit([Bind(Include = "id,createdAt,updatedAt,version,deleted,datumPolaska,datumPovratka,minBrojPutnika,maxBrojPutnika,opisPutovanja,istaknuto,idAgencije,idDestinacije,idHotela,idPrevoz,cijena")] PutovanjeAzure putovanjeAzure) { if (ModelState.IsValid) { db.Entry(putovanjeAzure).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(putovanjeAzure)); }
public ActionResult Edit([Bind(Include = "id,createdAt,updatedAt,version,deleted,ime,prezime,jmbg,datumRodjenja,telefon,email,sifra,idKartice")] KorisnikAzure korisnikAzure) { if (ModelState.IsValid) { db.Entry(korisnikAzure).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(korisnikAzure)); }
public ActionResult Edit([Bind(Include = "id,createdAt,updatedAt,version,deleted,naziv,drzava,kontinent,slika")] DestinacijaAzure destinacijaAzure) { if (ModelState.IsValid) { db.Entry(destinacijaAzure).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(destinacijaAzure)); }
public ActionResult Edit([Bind(Include = "CarId,Plate,Model,Year,Capacity,Logo,Logo1,Logo2,Observation")] Car car) { if (ModelState.IsValid) { db.Entry(car).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(car)); }
public ActionResult Edit([Bind(Include = "id,createdAt,updatedAt,version,deleted,naziv,idKartica,telefon,grad,lokacija,sifra,email")] AgencijaAzure agencijaAzure) { if (ModelState.IsValid) { db.Entry(agencijaAzure).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(agencijaAzure)); }
public ActionResult Edit([Bind(Include = "id,createdAt,updatedAt,version,deleted,ime,vrstaPrevoza,maxKapacitet,kapacitet,cijena,idDestinacije")] PrevozAzure prevozAzure) { if (ModelState.IsValid) { db.Entry(prevozAzure).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(prevozAzure)); }
public ActionResult Edit([Bind(Include = "ID,firstName,lastName,workedYear,img")] Guider guider) { if (ModelState.IsValid) { db.Entry(guider).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(guider); }
public ActionResult Edit([Bind(Include = "userID,userName,password,firstName,lastName,email,phone,regNo,gender,birthDate,roleID")] User user) { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.roleID = new SelectList(db.Roles, "ID", "name", user.roleID); return(View(user)); }
public ActionResult Edit([Bind(Include = "hotelID,name,detail,room,maxPerson,TravelID")] Hotel hotel) { if (ModelState.IsValid) { db.Entry(hotel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TravelID = new SelectList(db.Travels, "ID", "Name", hotel.TravelID); return(View(hotel)); }
public ActionResult Edit([Bind(Include = "Id,PlaceId,Title,ShortDescription,Text,Status,ImageName")] Place place) { if (ModelState.IsValid) { db.Entry(place).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PlaceId = new SelectList(TravelClass.DropDown.PlaceIdTitles(), "Id", "Title", place.PlaceId); return(View(place)); }
public ActionResult Edit([Bind(Include = "dayID,day,detail,travelPlanID")] Day day) { if (ModelState.IsValid) { db.Entry(day).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.travelPlanID = new SelectList(db.Plans, "ID", "detail", day.travelPlanID); return(View(day)); }
public ActionResult Edit([Bind(Include = "imageID,source,TravelID")] Image image) { if (ModelState.IsValid) { db.Entry(image).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TravelID = new SelectList(db.Travels, "ID", "Name", image.TravelID); return(View(image)); }
public ActionResult Edit([Bind(Include = "ID,Name,StartFrom,EndTo,TravelTypeID,guiderID")] Travel travel) { if (ModelState.IsValid) { db.Entry(travel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.guiderID = new SelectList(db.Guides, "ID", "firstName", travel.guiderID); ViewBag.TravelTypeID = new SelectList(db.TravelTypes, "TravelTypeID", "Name", travel.TravelTypeID); return(View(travel)); }
public ActionResult Edit([Bind(Include = "CityId,Name,DepartmentId")] City city) { if (ModelState.IsValid) { db.Entry(city).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DepartmentId = new SelectList( CombosHelper.GetDepartments(), "DepartmentId", "Name", city.DepartmentId); return(View(city)); }
public NoteViewModel UpdateNoteItem(int noteId, NoteFormViewModel model) { var note = _context.Notes.FirstOrDefault(n => n.Id == noteId); if (note == null) { return(null); } note.Title = model.Title; note.Text = model.Text; _context.Entry(note).State = EntityState.Modified; _context.SaveChanges(); return(new NoteViewModel { Id = note.Id, Title = note.Title, Text = note.Text }); }