public ActionResult Edit(updateProject acc) { if (ModelState.IsValid) { var dao = new workDao(); var result = dao.update(acc); if (result) { return(RedirectToAction("Index", "Work")); } else { ModelState.AddModelError("", "Cập nhập thành công"); } } return(View("Index")); }
//view update public ActionResult Edit(int id) { var w = new workDao().viewDetail(id); var updateProject = new updateProject(); updateProject.Id = w.Id; updateProject.nameProject = w.nameProject; updateProject.nameLeader = w.Leader; updateProject.dateWork = w.dateWork; updateProject.dateEnd = w.dateFinsinh; updateProject.numjoin = w.numJoin; var db = new userDao(); var a = db.listAllWithWorkId(id); ViewBag.dsNv = new MultiSelectList(db.listAll(), "ID", "Name", db.listAllWithWorkId(id)); return(View(updateProject)); }
public void Put(int id, [FromBody] updateProject projects) { using (DreamFountainDBEntities entities = new DreamFountainDBEntities()) { var entity = entities.Projects.FirstOrDefault(x => x.Project_ID == id); entity.Description = projects.description; entity.Title = projects.title; entity.Video = projects.video; entity.Category_ID = Int32.Parse(projects.category); entity.Subcategory_ID = Int32.Parse(projects.subcategory); entities.SaveChanges(); ProjectImagesController img = new ProjectImagesController(); ProjectImagesController.updateProjectImg bytes = new ProjectImagesController.updateProjectImg(); bytes.image = projects.image; img.Put(id, bytes); } }