public List <CommentUnion> GetComments(Int32 customerId, Int32 parentId, CommonUnit.CommentType type) { menuzRusDataContext db = new menuzRusDataContext(base.connectionString); CheckMenuComment checkMenuComment; List <CommentUnion> retVal = new List <CommentUnion>(); IEnumerable <Comment> comments = db.Comments.Where(m => m.CustomerId == customerId); IEnumerable <CheckMenuComment> checkMenuComments = db.CheckMenuComments.Where(m => m.ParentId == parentId && m.Type == (Int32)type); foreach (Comment comment in comments) { CommentUnion comm = new CommentUnion(); comm.id = comment.id; comm.CommentText = comment.CommentText; comm.ParentId = 0; comm.Selected = false; checkMenuComment = checkMenuComments.FirstOrDefault(m => m.CommentId == comment.id); if (checkMenuComment != default(CheckMenuComment)) { comm.ParentId = checkMenuComment.ParentId; comm.Selected = true; } retVal.Add(comm); } return(retVal); }
private CommentsModel GetModel(Int32 parentId, CommonUnit.CommentType type) { CommentsModel model = new CommentsModel(); model.Comments = new List <Models.Comment>(); try { List <CommentUnion> comments = _commentService.GetComments(SessionData.customer.id, parentId, type); foreach (CommentUnion comment in comments) { Models.Comment comm = new Models.Comment(); comm.id = comment.id; comm.ParentId = comment.ParentId; comm.CommentText = comment.CommentText; comm.Selected = comment.Selected; model.Comments.Add(comm); } } catch (Exception ex) { base.Log(ex); } finally { } return(model); }
public String GetItemComment(Int32 parentId, CommonUnit.CommentType type, Int32 customerId) { menuzRusDataContext db = new menuzRusDataContext(base.connectionString); String[] query = (from com in db.Comments join cmc in db.CheckMenuComments on com.id equals cmc.CommentId where com.CustomerId == customerId && cmc.ParentId == parentId && cmc.Type == (Int32)type select com.CommentText).ToArray(); return(String.Join(" | ", query)); }
public Int32 SaveComment(Int32 id, Int32 parentId, CommonUnit.CommentType type) { CheckMenuComment query = new CheckMenuComment(); try { using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) { query.Type = (Int32)type; query.ParentId = parentId; query.CommentId = id; db.CheckMenuComments.InsertOnSubmit(query); db.SubmitChanges(); } } catch (Exception ex) { } return(query.id); }
public Boolean DeleteComment(Int32 id, Int32 parentId, CommonUnit.CommentType type) { CheckMenuComment query; try { using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) { query = db.CheckMenuComments.FirstOrDefault(m => m.CommentId == id && m.ParentId == parentId && m.Type == (Int32)type); if (query != default(CheckMenuComment)) { db.CheckMenuComments.DeleteOnSubmit(query); db.SubmitChanges(); } } } catch (Exception ex) { return(false); } return(true); }