public async Task <IHttpActionResult> EditHotel(int id, HotelViewModel hotel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } TestDBEntities db = new TestDBEntities(); var existingHotel = await db.Hotels.Where(h => h.ID == id).SingleOrDefaultAsync(); if (existingHotel == null) { return(BadRequest("Object not found")); } existingHotel.Name = hotel.Name; existingHotel.LastUpdate = DateTime.Now; db.Hotels.Attach(existingHotel); var entry = db.Entry(existingHotel); entry.Property(h => h.Name).IsModified = true; entry.Property(h => h.LastUpdate).IsModified = true; await db.SaveChangesAsync(); return(Ok()); }
public async Task <IHttpActionResult> PutInvoice(string id, Invoice invoice) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != invoice.InvoiceId) { return(BadRequest()); } db.Entry(invoice).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InvoiceExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// Updates an employee with a new data /// </summary> /// <param name="employee"></param> public void EditEmployee(Empoyee employee) { using (TestDBEntities entities = new TestDBEntities()) { entities.Entry(employee).State = EntityState.Modified; entities.SaveChanges(); } }
public ActionResult Edit(Product_Info product_Info, HttpPostedFileBase file) { if (ModelState.IsValid) { if (product_Info != null) { if (file != null) { string path = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(file.FileName)); file.SaveAs(path); Product_Info product = new Product_Info(); product.Product_Id = product_Info.Product_Id; product.Name = product_Info.Name; product.Description = product_Info.Description; product.Price = product_Info.Price; product.Image = "Images/" + file.FileName; db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } else { //string path = Path.Combine(Server.MapPath("~/Images"), "DefaultImg.png"); string path = "Images/DefaultImg.png"; //file.SaveAs(path); Product_Info product = new Product_Info(); product.Product_Id = product_Info.Product_Id; product.Name = product_Info.Name; product.Description = product_Info.Description; product.Price = product_Info.Price; product.Image = path; db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } } return(View(product_Info)); }
public ActionResult Edit([Bind(Include = "ID,CampaignName,Date,Clicks,Conversions,Impressions,AffiliateName")] DevTest devTest) { if (ModelState.IsValid) { db.Entry(devTest).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(devTest)); }
public ActionResult Edit([Bind(Include = "Department_Code,Part_Code,Module_Code,Module_Title,Active")] timetable_module timetable_module) { if (ModelState.IsValid) { db.Entry(timetable_module).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(timetable_module)); }
public ActionResult Edit([Bind(Include = "SUPPLIER_ID,SUPPLIERS_NAME,ADDRESS,PHONE_NUMBER,isActive")] SUPPLIERS sUPPLIERS) { if (ModelState.IsValid) { db.Entry(sUPPLIERS).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(sUPPLIERS)); }
public ActionResult Edit([Bind(Include = "EmpID,Name,City,MobileNo,birthdate,Email")] tblEmp tblEmp) { if (ModelState.IsValid) { db.Entry(tblEmp).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblEmp)); }
public ActionResult Edit([Bind(Include = "Facility_ID,Facility_Name")] timetable_facility timetable_facility) { if (ModelState.IsValid) { db.Entry(timetable_facility).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(timetable_facility)); }
public ActionResult Edit([Bind(Include = "MemberID,Password,UserName,Email,Age,CellPhone,Blog,CreateDate")] Members members) { if (ModelState.IsValid) { db.Entry(members).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(members)); }
public ActionResult Edit(Employee employee) { if (ModelState.IsValid) { db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(employee)); }
public ActionResult Edit([Bind(Include = "ITEM_ID,ITEM_DESRIPTION,CATEGORY_ID,isActive")] ITEMS iTEMS) { if (ModelState.IsValid) { db.Entry(iTEMS).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(iTEMS)); }
public ActionResult Edit([Bind(Include = "Park_ID,Building_ID,Room_ID,Capacity,Type_ID")] timetable_room timetable_room) { if (ModelState.IsValid) { db.Entry(timetable_room).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(timetable_room)); }
public ActionResult Edit(logininfo logininfo) { if (ModelState.IsValid) { db.Entry(logininfo).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(logininfo)); }
public ActionResult Update(Contact objContact, int id) { Contact cont = db.Contacts.Find(id); cont.Name = objContact.Name; cont.Address = objContact.Address; cont.Contact_Number = objContact.Contact_Number; db.Entry(cont); db.SaveChanges(); objCont.contactList = db.Contacts.ToList(); return(View("Index", objCont.contactList)); }
public async Task <ActionResult> Edit([Bind(Include = "ProdId,ProdNombre,CatId,Precio,ProdObservacion")] tblProduct tblProduct) { if (ModelState.IsValid) { db.Entry(tblProduct).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.CatId = new SelectList(db.tblProductCategory, "CatId", "CatNombre", tblProduct.CatId); return(View(tblProduct)); }
public ActionResult Edit([Bind(Include = "PURCHASE_ID,PURCHASE_NUMBER,ITEM_ID,PRICE,QUANTITY,PURCHASE_DATE,STOCK_ID,SUPPLIER_ID")] ITEMS_PURCHASE iTEMS_PURCHASE) { if (ModelState.IsValid) { db.Entry(iTEMS_PURCHASE).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ITEM_ID = new SelectList(db.ITEMS, "ITEM_ID", "ITEM_DESRIPTION", iTEMS_PURCHASE.ITEM_ID); ViewBag.STOCK_ID = new SelectList(db.STOCKS, "STOCK_ID", "ADDRESS", iTEMS_PURCHASE.STOCK_ID); ViewBag.SUPPLIER_ID = new SelectList(db.SUPPLIERS, "SUPPLIER_ID", "SUPPLIERS_NAME", iTEMS_PURCHASE.SUPPLIER_ID); return(View(iTEMS_PURCHASE)); }
public ActionResult Edit([Bind(Include = "MOVE_ORDER_ID,MOVE_ORDER_NUMBER,ITEM_ID,PRICE,QUANTITY,STORE_ID,STOCK_ID")] MOVE_ORDERS mOVE_ORDERS) { if (ModelState.IsValid) { db.Entry(mOVE_ORDERS).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ITEM_ID = new SelectList(db.ITEMS, "ITEM_ID", "ITEM_DESRIPTION", mOVE_ORDERS.ITEM_ID); ViewBag.STOCK_ID = new SelectList(db.STOCKS, "STOCK_ID", "ADDRESS", mOVE_ORDERS.STOCK_ID); ViewBag.STORE_ID = new SelectList(db.STORE, "STORE_ID", "STORE_NAME", mOVE_ORDERS.STORE_ID); return(View(mOVE_ORDERS)); }
public ActionResult Edit(EMPLOYEE employee) { if (ModelState.IsValid) { db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); MessageBox.Show("processed correctly"); } return(View(employee)); MessageBox.Show("processed correctly"); }
public ActionResult Edit([Bind(Include = "Request_ID,Department_Code,Part_Code,Module_Code,Day_ID,Start_Time,Duration,Number_Students,Number_Rooms,Priority,Room_Type,Park_ID,Custom_Comments,Current_Year,Current_Semester,Current_Round,Request_Status")] timetable_request timetable_request) { if (ModelState.IsValid) { db.Entry(timetable_request).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Day_ID = new SelectList(db.timetable_day, "Day_ID", "Day_Name", timetable_request.Day_ID); ViewBag.Department_Code = new SelectList(db.timetable_module, "Department_Code", "Module_Title", timetable_request.Department_Code); ViewBag.Request_ID = new SelectList(db.timetable_request, "Request_ID", "Department_Code", timetable_request.Request_ID); ViewBag.Request_ID = new SelectList(db.timetable_request, "Request_ID", "Department_Code", timetable_request.Request_ID); ViewBag.Request_ID = new SelectList(db.timetable_request_room_allocation, "Request_ID", "Building_ID", timetable_request.Request_ID); ViewBag.Request_ID = new SelectList(db.timetable_request_week, "Request_ID", "Request_ID", timetable_request.Request_ID); return(View(timetable_request)); }
public ActionResult StoreOrEdit(tbl_Student studentob) { using (TestDBEntities db = new TestDBEntities()) { if (studentob.Id == 0) { db.tbl_Student.Add(studentob); db.SaveChanges(); return(Json(new { success = true, message = "Saved Successfully", JsonRequestBehavior.AllowGet })); } else { db.Entry(studentob).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "Updated Successfully", JsonRequestBehavior.AllowGet })); } } }
public IHttpActionResult PutEmployee(int id, Employee employee) { if (!ModelState.IsValid) { return(NotFound()); } if (id != employee.EmployeeID) { return(NotFound()); } if (ModelState.IsValid) { db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); return(Ok()); } else { return(NotFound()); } }