Ejemplo n.º 1
0
 public ActionResult Edit([Bind(Include = "UserId,FirstName,LastName,BirhtDate,Email,Phone,AddDate,ModifiedDate,IsActive")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
Ejemplo n.º 2
0
        public IHttpActionResult PutModel(int id, Model model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != model.ModelId)
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "CarId,Brand,Model,Mileage,ReleaseDate,BodyTypeId,Count,AddDate,ModifiedDate")] Car car)
 {
     if (ModelState.IsValid)
     {
         db.Entry(car).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Secound"));
     }
     ViewBag.BodyTypeId = new SelectList(db.CarBodyType, "BodyTypeId", "Name", car.BodyTypeId);
     return(PartialView("_Popup", car));
 }
Ejemplo n.º 4
0
        public ActionResult Return(int id)
        {
            Borrow item = db.Borrow.Where(x => x.BorrowId == id).FirstOrDefault();

            db.Borrow.Attach(item);
            db.Entry(item).Property(x => x.IsReturned).CurrentValue = true;
            Car caritem = db.Car.Where(x => x.CarId == item.CarId).FirstOrDefault();

            Car car = db.Car.Find(item.CarId);

            if (car == null)
            {
                return(HttpNotFound());
            }
            car.Count += 1;
            db.Car.Attach(car);
            db.Entry(car).Property(x => x.Count).IsModified = true;
            db.SaveChanges();

            ViewData["cars"] = db.CarBodyType;
            return(RedirectToAction("Index"));
        }