/// <summary> /// Deletes the car from the database. /// </summary> /// <param name="carId">The car which is wanted to delete from database.</param> /// <returns>Boolean value whether the transaction is happened or not.</returns> public static bool DeleteCar(string carId) { bool result = CarPersistence.DeleteCar(carId); result = CommentPersistence.DeleteCommentFromCarID(carId); return(result); }
public ActionResult AddComment(Comment comment, String sTitle) { System.Diagnostics.Debug.WriteLine("sesss" + Session["LoggedIn"]); if (Session["LoggedIn"] == null || Session["LoggedIn"].Equals(false) || Session["LoggedIn"].ToString().Length == 0) { TempData["commentAdded"] = "Please Log in."; return(View(comment)); } comment.Writer = UserPersistence.GetUser(Session["userId"].ToString()); comment.CommentId = CommentPersistence.getMaxId() + 1; System.Diagnostics.Debug.WriteLine("***" + sTitle); comment.Service = ServicePersistence.GetService(sTitle); bool?acceptible = false; acceptible = CommentManager.AddNewComment(comment); if ((acceptible != null)) { if (acceptible == true) { TempData["commentAdded"] = "Comment is added successfully."; return(RedirectToAction("Index", "Home")); } else { TempData["commenteAdded"] = "Comment could not be added."; return(View(comment)); } } else { TempData["commentAdded"] = "Comment could not be added."; return(View(comment)); } }
public ActionResult ServiceDetail(String title) { Service service = ServicePersistence.GetService(title); service.Comments = CommentPersistence.getCommentsForaService(service); Comment comment = new Comment(); comment.Service = service; return(View(Tuple.Create(service, comment))); }
public static bool AddNewComment(Comment newComment) { // Verify that the service doesn't already exist Comment oldComment = CommentPersistence.GetComment(newComment.CommentId); // oldService should be null, if this is a new service if (oldComment != null) { return(false); } return(CommentPersistence.AddComment(newComment)); }
public ActionResult DeleteComment(string CommentId) { bool result = CommentManager.DeleteComment(CommentId); if (result) { ViewBag.message = "Comment successfully deleted."; } else { ViewBag.message = "Comment could not be deleted."; } return(View(CommentPersistence.GetUserComment(Session["UserId"].ToString()))); }
public ActionResult AddComment(Comment comment, String sTitle) { System.Diagnostics.Debug.WriteLine("sesss" + Session["LoggedIn"]); if (Session["LoggedIn"] == null || Session["LoggedIn"].Equals(false) || Session["LoggedIn"].ToString().Length == 0) { TempData["commentAdded"] = "Please Log in."; return(RedirectToAction("ServiceDetail", "Service", new { title = sTitle })); } comment.Writer = UserPersistence.GetUser(Session["userId"].ToString()); comment.CommentId = CommentPersistence.getMaxId() + 1; System.Diagnostics.Debug.WriteLine("***" + sTitle); comment.Service = ServicePersistence.GetService(sTitle); bool?acceptible = false; string t = comment.Content.Replace("<", "<"); string t1 = t.Replace(">", ">"); string t2 = t1.Replace("(", "("); string t3 = t2.Replace(")", ")"); string t4 = t3.Replace("&", "&"); t4 = t4.Replace("'", ""); string tfinal = t4.Replace("|", "|"); comment.Content = tfinal; acceptible = CommentManager.AddNewComment(comment); if ((acceptible != null)) { if (acceptible == true) { TempData["commentAdded"] = "Comment is added successfully."; return(RedirectToAction("Index", "Home")); } else { TempData["commentAdded"] = "Comment could not be added."; return(RedirectToAction("ServiceDetail", "Service", new { title = sTitle })); } } else { TempData["commentAdded"] = "Comment could not be added."; return(RedirectToAction("ServiceDetail", "Service", new { title = sTitle })); } }
public ActionResult AddService(Service service) { if (Session["userId"] == null || Session["IsProvider"].Equals(false)) { TempData["serviceAdded"] = "Please Log in."; return(View(service)); } service.Owner = UserPersistence.GetUser(Session["userId"].ToString()); service.Comments = CommentPersistence.getCommentsForaService(service); service.date = DateTime.Now; string t = service.Description.Replace("<", "<"); string t1 = t.Replace(">", ">"); string t2 = t1.Replace("(", "("); string t3 = t2.Replace(")", ")"); string t4 = t3.Replace("&", "&"); t4 = t4.Replace("'", ""); string tfinal = t4.Replace("|", "|"); service.Description = tfinal; bool?acceptible = false; acceptible = ServiceManager.AddNewService(service); if ((acceptible != null)) { if (acceptible == true) { TempData["serviceAdded"] = "Service is added successfully."; return(RedirectToAction("Index", "Home")); } else { TempData["serviceAdded"] = "Service could not be added."; return(View(service)); } } else { TempData["serviceAdded"] = "Service could not be added."; return(View(service)); } }
/// <summary> /// Calculates the statistics and puts them into the array. /// </summary> /// <returns>An integer of length 5 which contains the count of count of the number of users (total, active, and inactive), records, ///and comments, in this order. ///</returns> public static int[] GetStatistics() { int[] stats = new int[5]; for (int i = 0; i < 5; i++) { stats[i] = 0; } User[] users = UserPersistence.GetAllUsers(); List <Car> cars = CarPersistence.GetAllCars(); for (int i = 0; i < users.Length; i++) // Counts for the users that are active, inactive and total. { if (users[i].status == "A") { stats[1]++; } else { stats[2]++; } stats[0]++; } for (int i = 0; i < cars.Count; i++) // Counts the cars in the database. { stats[3]++; } List <Comment> comments = CommentPersistence.GetAllComments(); for (int i = 0; i < comments.Count; i++) // Counts the comments in the system. { stats[4]++; } return(stats); }
public ActionResult DeleteComment() { return(View(CommentPersistence.GetUserComment(Session["UserId"].ToString()))); }
/// <summary> /// Deletes the comment with given commentId. /// </summary> /// <param name="commentId">Comment that is wanted to be deleted.</param> /// <returns>Boolean value whether the transaction is happened or not.</returns> public static bool DeleteComment(string commentId) { bool result = CommentPersistence.DeleteComment(commentId); return(result); }
/// <summary> /// Adds the comment into the database. /// </summary> /// <param name="newComment">Comment that wanted to be added.</param> /// <returns>Boolean value whether the transaction is happened or not.</returns> public static bool AddNewComment(Comment newComment) { return(CommentPersistence.AddComment(newComment)); }
/// <summary> /// Gets car's comments which is selected by user. /// </summary> /// <param name="CarId">Car which user wants to look at its comments.</param> /// <returns>Comments that entered to this car.</returns> public static Comment[] GetCarComments(int CarId) { Comment[] comments = CommentPersistence.GetCarComment(CarId); return(comments); }
/// <summary> /// Gets users comments. /// </summary> /// <param name="UserId">User that wants to see his/her comments.</param> /// <returns>Comments that user enters to cars.</returns> public static Comment[] GetUserComments(string UserId) { Comment[] comments = CommentPersistence.GetUserComment(UserId); return(comments); }