示例#1
0
 /// <summary>
 /// Generic Delete method for the entities
 /// </summary>
 /// <param name="entityToDelete"></param>
 public virtual void Delete(TEntity entityToDelete)
 {
     if (Context.Entry(entityToDelete).State == EntityState.Detached)
     {
         DbSet.Attach(entityToDelete);
     }
     DbSet.Remove(entityToDelete);
 }
示例#2
0
        public async Task <IHttpActionResult> PutEmployee(int id, Employee employee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != employee.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#3
0
 public ActionResult Edit([Bind(Include = "Id,Name,Dob,Salary,CreateUser,CreateDate,UpdateUser,UpdateDate")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(employee));
 }
 public ActionResult Edit([Bind(Include = "ProductID,Name,Price")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(Redirect("~/Umbraco/Surface/Products/Index"));
         //return RedirectToAction("Index");
     }
     return(View(product));
 }
示例#5
0
 public ActionResult Edit([Bind(Include = "Id,ProductName,SupplierId,UnitPrice,Package,IsDiscontinued")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.SupplierId = new SelectList(db.Suppliers, "Id", "CompanyName", product.SupplierId);
     return(View(product));
 }