コード例 #1
0
        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);
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        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());
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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());
        }
コード例 #7
0
        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));
        }
コード例 #8
0
 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();
     }
 }
コード例 #9
0
ファイル: Service.cs プロジェクト: HappyFreddie/TravelNotepad
 public virtual void Update(T entity)
 {
     if (entity == null)
     {
         throw new ArgumentNullException("请提供泛型类别");
     }
     db.Entry(entity).State = EntityState.Modified;
     db.SaveChanges();
 }
コード例 #10
0
 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));
 }
コード例 #11
0
 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));
 }
コード例 #12
0
 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));
 }
コード例 #13
0
 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));
 }
コード例 #14
0
 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));
 }
コード例 #15
0
 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));
 }
コード例 #16
0
 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));
 }
コード例 #17
0
 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));
 }
コード例 #18
0
 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));
 }
コード例 #19
0
 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));
 }
コード例 #20
0
 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));
 }
コード例 #21
0
 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));
 }
コード例 #22
0
 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);
 }
コード例 #23
0
 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));
 }
コード例 #24
0
 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));
 }
コード例 #25
0
 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));
 }
コード例 #26
0
ファイル: DaysController.cs プロジェクト: Dauletbek/TravelWeb
 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));
 }
コード例 #27
0
 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));
 }
コード例 #28
0
 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));
 }
コード例 #29
0
 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));
 }
コード例 #30
0
        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
            });
        }