Exemplo n.º 1
0
        private static bool CheckIfCommentCanBeAdded(Workshop_Comments comment)
        {
            // TODO:
            // Check if there is any sense in here
            // I have no idea if it works correctly xD
            var mustBeOlderThat = DateTime.Now.AddDays(-minTimeBetweenCommentsInDays);

            var db = new ITAPPCarWorkshopServiceDBEntities();

            if (!db.Workshop_Comments.Any(n => n.Workshop_ID == comment.Workshop_ID && n.Client_ID == comment.Client_ID))
            {
                return(true);
            }

            var list = db.Workshop_Comments.Where(n => n.Workshop_ID == comment.Workshop_ID && n.Client_ID == comment.Client_ID).OrderByDescending(n => n.Comment_date).ToList();

            var lastCommentDate = list.First().Comment_date;

            if (lastCommentDate < mustBeOlderThat)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        public static void EditComment(Workshop_Comments editedComment)
        {
            // TODO:
            // check if the comment exists - method - may throw exception
            // get the comment to be edited
            // edit the comment to be edited
            // save changes to DB
            // return the result

            // remember about mutex
        }
Exemplo n.º 3
0
        public static void AddComment(Workshop_Comments newComment)
        {
            // TODO:
            // check if the user has already added a comment of the workshop in last XXX hours/days/weeks/months - method - may throw exception
            // check if user exists - method from user manager - may throw exception
            // check if workshop exists - method from workshop profile manager - may throw exception
            // add a new comment to DB
            // return the result

            // remember about mutex
        }
 public Response_String Add_Comment([FromBody] Workshop_Comments New_Comment)
 {
     using (var db = new ITAPPCarWorkshopServiceDBEntities())
     {
         db.Workshop_Comments.Add(New_Comment);
         db.SaveChanges();
         return(new Response_String()
         {
             Response = "Item was added"
         });
     }
 }
 public Response_String Modify_Comment([FromBody] Workshop_Comments Modify_Comment)
 {
     using (var db = new ITAPPCarWorkshopServiceDBEntities())
     {
         var Old = db.Workshop_Comments.FirstOrDefault(p => Modify_Comment.Comment_ID == p.Comment_ID);
         if (Old != null)
         {
             var ID = Old.Comment_ID;
             Old            = Modify_Comment;
             Old.Comment_ID = ID;
             db.SaveChanges();
             return(new Response_String()
             {
                 Response = "Item was modify"
             });
         }
         return(new Response_String()
         {
             Response = "Item does not exsists"
         });
     }
 }