Пример #1
0
        public async Task <IHttpActionResult> PutCountry(int id, Country country)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != country.ID)
            {
                return(BadRequest());
            }

            db.Entry(country).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IActionResult> PutCountry(short id, Country country)
        {
            if (id != country.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Пример #3
0
 public ActionResult Edit([Bind(Include = "CustomerID,CustomerName,CustomerPIN")] Customer customer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(customer));
 }
Пример #4
0
 public ActionResult Edit(Country country)
 {
     if (ModelState.IsValid)
     {
         db.Entry(country).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(country));
 }
Пример #5
0
        public ActionResult UpdateCountry(Country country)
        {
            var result = false;

            if (ModelState.IsValid)
            {
                db.Entry(country).State = EntityState.Modified;
                db.SaveChanges();
                result = true;
            }
            return(Json(new { success = result }, JsonRequestBehavior.AllowGet));
        }
Пример #6
0
        public void Update(Country entity)
        {
            _context.Entry(entity).State = EntityState.Modified;

            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
 public void Edit(Country obj)
 {
     Context.Entry(obj).State = EntityState.Modified;
     Context.SaveChanges();
 }