Exemplo n.º 1
0
        public IActionResult Detail(string ID = "")
        {
            var _user = HttpContext.Session.GetSession <User>("User");

            NoteInfoModel detail = _noteManager.GetNoteInfo(ID, _user?.ID);

            if (detail != null)
            {
                detail.Group = (detail.Group != null) ? _groupManager.GetGroupInfo(detail.Group.ID, _user?.ID) :
                               (detail.Folder != null) ? _groupManager.GetGroupInfo(detail.Folder.GroupID, _user?.ID) : null;
            }

            return(View(detail));
        }
Exemplo n.º 2
0
        public NoteInfoModel GetNoteInfo(string NoteID = "", string UserID = "")
        {
            NoteInfoModel detail = null;

            var _note = noteDal.getMany(a => a.ID == NoteID)
                        .Include(a => a.Group)
                        .Include(a => a.Folder)
                        .ThenInclude(b => b.Group)
                        .Include(a => a.Users)
                        .ThenInclude(b => b.User)
                        .FirstOrDefault();

            if (_note != null)
            {
                detail             = new NoteInfoModel();
                detail.ID          = _note.ID;
                detail.Title       = _note.Title;
                detail.Explanation = _note.Explanation;
                detail.Content     = _note.Content;
                detail.CreateDate  = _note.CreateDate;
                detail.UpdateDate  = _note.UpdateDate;
                detail.Visible     = _note.Visible;
                detail.ReadCount   = _note.ReadCount;
                detail.Folder      = _note.Folder;
                detail.Group       = _note.Group != null ? new GroupInfoModel {
                    ID = _note.GroupID
                } : null;
                detail.User = _note.Users.FirstOrDefault(a => a.Status == Status.Owner).User;

                var _user = _note.Users.FirstOrDefault(a => a.UserID == UserID);
                detail.Status = (_user != null) ? _user.Status : (!string.IsNullOrEmpty(UserID)) ? Status.User : Status.Visitor;

                UpdateNoteReadCount(_note);
            }

            return(detail);
        }