public Task <JsonResponse> PostFeedback(int reasonID, string comment, int react, string fullname) { return(Task.Run(() => { using (MIUEntities db = new MIUEntities()) { try { StudentFeedback feedback = new StudentFeedback() { ReasonID = reasonID, Comment = comment, React = react, CreatedBy = fullname, CreatedDate = DateTime.Now }; db.StudentFeedbacks.Add(feedback); db.SaveChanges(); return new JsonResponse() { Flag = true, Message = "Successfully Saved" }; } catch (Exception ex) { return new JsonResponse() { Flag = true, Message = ex.Message }; } } })); }
public ActionResult Update(StudentFeedback studentFeedback) { if (ModelState.IsValid) { StudentFeedback StudentFeedback = db.StudentFeedbacks.Find(studentFeedback.Id); if (studentFeedback.ImageFile != null) { string imageName = DateTime.Now.ToString("ddMMyyyyHHmmssffff") + studentFeedback.ImageFile.FileName; string imagePath = Path.Combine(Server.MapPath("~/Uploads/img"), imageName); string OldimagePath = Path.Combine(Server.MapPath("~/Uploads/img"), StudentFeedback.Image); System.IO.File.Delete(OldimagePath); studentFeedback.ImageFile.SaveAs(imagePath); StudentFeedback.Image = imageName; } StudentFeedback.FullName = studentFeedback.FullName; StudentFeedback.Category = studentFeedback.Category; StudentFeedback.Content = studentFeedback.Content; StudentFeedback.CreatedDate = studentFeedback.CreatedDate; db.Entry(StudentFeedback).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(studentFeedback)); }
public CMSResult Save(StudentFeedback newStudentFeedback) { var result = new CMSResult(); _repository.Add(newStudentFeedback); result.Results.Add(new Result { IsSuccessful = true, Message = string.Format("Student Feedback '{0}' added successfully!", newStudentFeedback.Name) }); return(result); }
public ActionResult Delete(int id) { StudentFeedback studentFeedback = db.StudentFeedbacks.Find(id); if (studentFeedback == null) { return(HttpNotFound()); } db.StudentFeedbacks.Remove(studentFeedback); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Update(int id) { if (Session["AdminId"] == null) { return(RedirectToAction("Index", "Login")); } StudentFeedback studentFeedback = db.StudentFeedbacks.Find(id); if (studentFeedback == null) { return(HttpNotFound()); } return(View(studentFeedback)); }
public ActionResult Create(StudentFeedback studentFeedback) { if (ModelState.IsValid) { string imageName = DateTime.Now.ToString("ddMMyyyyHHmmssffff") + studentFeedback.ImageFile.FileName; string imagePath = Path.Combine(Server.MapPath("~/Uploads/img"), imageName); studentFeedback.ImageFile.SaveAs(imagePath); studentFeedback.Image = imageName; db.StudentFeedbacks.Add(studentFeedback); db.SaveChanges(); return(RedirectToAction("Index")); } return(View()); }
public void Put(int id, [FromBody] StudentFeedback studentFeedbackReq) { _dbcontext.Entry(_dbcontext.StudentFeedbacks.Where(X => X.StudentFeedbackId == id).FirstOrDefault()).CurrentValues.SetValues(studentFeedbackReq); _dbcontext.SaveChanges(); }
public void Post([FromBody] StudentFeedback studentFeedbackReq) { _dbcontext.StudentFeedbacks.Add(studentFeedbackReq); _dbcontext.SaveChanges(); }