public ActionResult updateSupervisingComment(SupervisingCommentViewModel model) { try { if (!ModelState.IsValid) { throw new Exception("Invalid Input"); } using (var db = new ApplicationDbContext()) { var comment = db.SupervisingComments.Where(x => x.Id == model.Id && x.SupervisorId == IMSUserUtil.Id).SingleOrDefault(); if (comment == null) { throw new Exception("Not Found!"); } comment.UpdatedAt = DateTime.UtcNow; comment.Comment = model.Comment; db.SaveChanges(); return(Json(new ImsResult { })); } } catch (Exception e) { return(Json(new IMS.Common.ImsResult { Error = e.Message })); } }
public ActionResult createSupervisingComment(SupervisingCommentViewModel model) { try { if (!ModelState.IsValid) { throw new Exception("Invalid Input"); } using (var db = new ApplicationDbContext()) { var comment = new SupervisingComment { Comment = model.Comment, CreatedAt = DateTime.UtcNow, UpdatedAt = DateTime.UtcNow, InternshipId = model.InternshipId, SupervisorId = IMSUserUtil.Id }; db.SupervisingComments.Add(comment); db.SaveChanges(); var supervisor = IMSUserUtil.DetachedUser; model.Id = comment.Id; model.CreatedAt = comment.CreatedAt; model.SupervisorId = IMSUserUtil.Id; model.SupervisorName = string.Format("{0} {1}", supervisor.FirstName, supervisor.LastName); return(Json(new ImsResult { Data = model })); } } catch (Exception e) { return(Json(new IMS.Common.ImsResult { Error = e.Message })); } }
public ActionResult deleteSupervisingComment(SupervisingCommentViewModel model) { try { using (var db = new ApplicationDbContext()) { var comment = db.SupervisingComments.Where(x => x.Id == model.Id && x.SupervisorId == IMSUserUtil.Id).SingleOrDefault(); if (comment == null) { throw new Exception("Not Found!"); } comment.IsActive = false; db.SaveChanges(); return(Json(new ImsResult { })); } } catch (Exception e) { return(Json(new IMS.Common.ImsResult { Error = e.Message })); } }