public IHttpActionResult PutFeedBack(int id, FeedBack feedBack) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != feedBack.FeedbackId) { return(BadRequest()); } db.Entry(feedBack).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!FeedBackExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit(Service service) { if (ModelState.IsValid) { //New Files for (int i = 0; i < Request.Files.Count; i++) { var file = Request.Files[i]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); FileServiceDetail fileDetail = new FileServiceDetail() { FileName = fileName, Extension = Path.GetExtension(fileName), Id = Guid.NewGuid(), ServiceId = service.ServiceId }; if (fileDetail.Extension == ".jpg") { var path = Path.Combine(Server.MapPath("~/App_Data/Upload_service/"), fileDetail.Id + fileDetail.Extension); file.SaveAs(path); } else { TempData["ErrorMessage"] = "Неправильное расширине файла для загрузки(только .jpg)"; return(RedirectToAction("Edit")); } db.Entry(fileDetail).State = EntityState.Added; } else { TempData["ErrorMessage"] = "Должна быть минимум 1 фотография"; return(RedirectToAction("Create")); } } db.Entry(service).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(service)); }
public ActionResult Edit([Bind(Include = "FeedbackId,Name,Email,Your_Feedback,Answer")] FeedBack feedBack) { if (ModelState.IsValid) { db.Entry(feedBack).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(feedBack)); }