コード例 #1
0
        /// <summary>
        /// Returns TRUE if a note was edited, FALSE otherwise.
        /// </summary>
        /// <param name="controlId"></param>
        /// <param name="note"></param>
        /// <returns></returns>
        public static async Task <bool> EditNoteAsync(NavigateControlId controlId, UserNote note)
        {
            var bookdb = BookDataContext.Get();

            var edited = false;
            var cd     = new ContentDialog()
            {
                Title               = "Edit Bookmark (Note)",
                PrimaryButtonText   = "OK",
                SecondaryButtonText = "Cancel"
            };
            var ne = new NoteEditor();

            ne.DataContext = note;
            cd.Content     = ne;
            var result = await cd.ShowAsync();

            switch (result)
            {
            case ContentDialogResult.Primary:
                ne.SaveNoteIfNeeded(controlId, bookdb);
                edited = true;
                break;

            case ContentDialogResult.Secondary:
                // Cancel means don't save the note.
                edited = false;
                break;
            }
            return(edited);
        }
コード例 #2
0
        /// <summary>
        /// Sets the contents of the given note.
        /// </summary>
        /// <param name="note">The note.</param>
        /// <param name="content">The content.</param>
        /// <returns>A modification result which may or may not have succeeded.</returns>
        public async Task <ModifyEntityResult> SetNoteContentsAsync(UserNote note, string content)
        {
            if (content.IsNullOrWhitespace())
            {
                return(ModifyEntityResult.FromError("You must provide some content for the note."));
            }

            if (content.Length > 1024)
            {
                return(ModifyEntityResult.FromError
                       (
                           "The note is too long. It can be at most 1024 characters."
                       ));
            }

            if (note.Content == content)
            {
                return(ModifyEntityResult.FromError("That's already the note's contents."));
            }

            note.Content = content;
            note.NotifyUpdate();

            await _database.SaveChangesAsync();

            return(ModifyEntityResult.FromSuccess());
        }
コード例 #3
0
    /// <summary>
    /// Posts a notification that a note was removed from a user.
    /// </summary>
    /// <param name="note">The note.</param>
    /// <param name="removerID">The person that removed the note.</param>
    /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
    public async Task <Result> NotifyUserNoteRemovedAsync(UserNote note, Snowflake removerID)
    {
        var getChannel = await GetModerationLogChannelAsync(note.Server.DiscordID);

        if (!getChannel.IsSuccess)
        {
            return(Result.FromError(getChannel));
        }

        var channel = getChannel.Entity;

        var eb = new Embed
        {
            Colour      = _feedback.Theme.Success,
            Title       = $"Note Removed (#{note.ID})",
            Description = $"A note was removed from <@{note.User.DiscordID}> (ID {note.User.DiscordID}) by " +
                          $"<@{removerID}>."
        };

        var sendResult = await _feedback.SendEmbedAsync(channel, eb);

        return(sendResult.IsSuccess
            ? Result.FromSuccess()
            : Result.FromError(sendResult));
    }
コード例 #4
0
        public void ShouldBeErrorNoKeyDelete()
        {
            string encryptionKey = null;
            DBResult <UserProfile> profileDBResult = new DBResult <UserProfile>
            {
                Payload = new UserProfile()
                {
                    EncryptionKey = encryptionKey
                }
            };

            Mock <IUserProfileDelegate> profileDelegateMock = new Mock <IUserProfileDelegate>();

            profileDelegateMock.Setup(s => s.GetUserProfile(hdid)).Returns(profileDBResult);

            UserNote userNote = new UserNote()
            {
                HdId            = hdid,
                Title           = "Deleted Note",
                Text            = "Deleted Note text",
                CreatedDateTime = new DateTime(2020, 1, 1)
            };

            INoteService service = new NoteService(
                new Mock <ILogger <NoteService> >().Object,
                new Mock <INoteDelegate>().Object,
                profileDelegateMock.Object,
                new Mock <ICryptoDelegate>().Object
                );

            RequestResult <UserNote> actualResult = service.DeleteNote(userNote);

            Assert.Equal(ResultType.Error, actualResult.ResultStatus);
        }
コード例 #5
0
        public IActionResult UpdateUserNoteDetails([FromBody] UserNote userNote)
        {
            _logger.InfoFormat("Request with verb [{0}] and Uri [{1}] executed", Request.Method, Request.Path);
            _logger.InfoFormat("Action UpdateUserNoteDetails started");
            try
            {
                //var noteDetails = _userNoteRepository.Get(e => e.Id == userNoteId);

                //var userNote = new UserNote
                //{
                //    Comment = comment,
                //    Username = noteDetails.FirstOrDefault().Username,
                //    Title = noteDetails.FirstOrDefault().Title,
                //    Note = noteDetails.FirstOrDefault().Note,
                //    ModifiedDate = noteDetails.FirstOrDefault().ModifiedDate,
                //};
                _userNoteRepository.Update(userNote);
                _userNoteRepository.Save();
                return(Ok(true));
            }
            catch (Exception ex)
            {
                _logger.InfoFormat("Action UpdateUserNoteDetails Failed");
                return(new JsonResult(ex));
            }
        }
コード例 #6
0
        /// <inheritdoc />
        public RequestResult <UserNote> CreateNote(UserNote userNote)
        {
            UserProfile profile = this.profileDelegate.GetUserProfile(userNote.HdId).Payload;
            string?     key     = profile.EncryptionKey;

            if (key == null)
            {
                this.logger.LogError($"User does not have a key: ${userNote.HdId}");
                return(new RequestResult <UserNote>()
                {
                    ResultStatus = ResultType.Error,
                    ResultError = new RequestResultError()
                    {
                        ResultMessage = "Profile Key not set", ErrorCode = ErrorTranslator.InternalError(ErrorType.InvalidState)
                    },
                });
            }

            Note note = userNote.ToDbModel(this.cryptoDelegate, key);

            DBResult <Note>          dbNote = this.noteDelegate.AddNote(note);
            RequestResult <UserNote> result = new RequestResult <UserNote>()
            {
                ResourcePayload = UserNote.CreateFromDbModel(dbNote.Payload, this.cryptoDelegate, key),
                ResultStatus    = dbNote.Status == DBStatusCode.Created ? ResultType.Success : ResultType.Error,
                ResultError     = dbNote.Status == DBStatusCode.Created ? null : new RequestResultError()
                {
                    ResultMessage = dbNote.Message, ErrorCode = ErrorTranslator.ServiceError(ErrorType.CommunicationInternal, ServiceType.Database)
                },
            };

            return(result);
        }
コード例 #7
0
        private async Task AnnounceUserNote(UserNote userNote, IUser actor, RestAction action)
        {
            using var scope = _serviceProvider.CreateScope();

            _logger.LogInformation($"Announcing usernote {userNote.GuildId}/{userNote.UserId} ({userNote.Id}).");

            GuildConfig guildConfig = await GuildConfigRepository.CreateDefault(scope.ServiceProvider).GetGuildConfig(userNote.GuildId);

            if (!string.IsNullOrEmpty(guildConfig.ModInternalNotificationWebhook))
            {
                _logger.LogInformation($"Sending internal webhook for usernote {userNote.GuildId}/{userNote.UserId} ({userNote.Id}) to {guildConfig.ModInternalNotificationWebhook}.");

                try
                {
                    IUser user = await _discordAPI.FetchUserInfo(userNote.UserId, CacheBehavior.Default);

                    EmbedBuilder embed = await userNote.CreateUserNoteEmbed(action, actor, user, scope.ServiceProvider);

                    await _discordAPI.ExecuteWebhook(guildConfig.ModInternalNotificationWebhook, embed.Build());
                }
                catch (Exception e)
                {
                    _logger.LogError(e, $"Error while announcing usernote {userNote.GuildId}/{userNote.UserId} ({userNote.Id}) to {guildConfig.ModInternalNotificationWebhook}.");
                }
            }
        }
コード例 #8
0
        public IActionResult PostUserNote(UserNoteDTO userNote)
        {
            var userid = _utils.VerifyRequest(userNote.token);

            if (userid is null)
            {
                return(StatusCode(403));
            }
            //调用百度API进行自然语言处理
            var client = _utils.GetBaiduClient();
            //情感分析
            var sentiment_result = client.SentimentClassify(userNote.content);
            //关键词提取
            var keywords = _services.ExtractKeywords(userNote.content);
            //存储
            var note = new UserNote();

            note.userid    = int.Parse(userid);
            note.content   = userNote.content;
            note.wordcount = userNote.wordcount;
            note.dateTime  = userNote.dateTime;
            note.sentiment = sentiment_result["items"][0].Value <int>("sentiment");
            note.tags      = keywords;
            _context.UserNote.Add(note);
            _context.SaveChanges();

            return(StatusCode(201));
        }
コード例 #9
0
        public IActionResult Post([FromBody] NotePost obj)
        {
            var note = SetTagAndLecture(obj);



            var user     = databaseUser.Read(obj.OwnerId);
            var userNote = new UserNote
            {
                User    = user,
                Note    = note,
                IsOwner = true
            };


            note.Users.Add(userNote);
            user.Notes.Add(userNote);

            var result = databaseNote.Create(note);



            if (result != null)
            {
                return(Ok(new NotePost(note)));
            }
            else
            {
                return(BadRequest(new { error = "User doesn't exist" }));
            }
        }
コード例 #10
0
    /// <summary>
    /// Posts a notification that a note was added to a user.
    /// </summary>
    /// <param name="note">The note.</param>
    /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
    public async Task <Result> NotifyUserNoteAddedAsync(UserNote note)
    {
        var getChannel = await GetModerationLogChannelAsync(note.Server.DiscordID);

        if (!getChannel.IsSuccess)
        {
            return(Result.FromError(getChannel));
        }

        var channel = getChannel.Entity;

        var eb = new Embed
        {
            Title       = $"Note Added (#{note.ID})",
            Colour      = Color.Gold,
            Description =
                $"A note was added to <@{note.User.DiscordID}> (ID {note.User.DiscordID}) by " +
                $"<@{note.Author.DiscordID}>.\n" +
                $"Contents: {note.Content}"
        };

        var sendResult = await _feedback.SendEmbedAsync(channel, eb);

        return(sendResult.IsSuccess
            ? Result.FromSuccess()
            : Result.FromError(sendResult));
    }
コード例 #11
0
        /// <summary>
        /// Posts a notification that a note was removed from a user.
        /// </summary>
        /// <param name="note">The note.</param>
        /// <param name="remover">The person that removed the note.</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        public async Task NotifyUserNoteRemoved(UserNote note, IGuildUser remover)
        {
            var guild      = _client.GetGuild((ulong)note.Server.DiscordID);
            var getChannel = await GetModerationLogChannelAsync(guild);

            if (!getChannel.IsSuccess)
            {
                return;
            }

            var channel = getChannel.Entity;

            var eb = _feedback.CreateEmbedBase();

            eb.WithTitle($"Note Removed (#{note.ID})");
            eb.WithColor(Color.Green);

            var notedUser = guild.GetUser((ulong)note.User.DiscordID);

            eb.WithDescription
            (
                $"A note was removed from {notedUser.Mention} (ID {notedUser.Id}) by {remover.Mention}."
            );

            await _feedback.SendEmbedAsync(channel, eb.Build());
        }
コード例 #12
0
        public async Task <Note> AddNote(long userId, long bookId, Note note)
        {
            _context.Note.Add(note);
            await _context.SaveChangesAsync();

            long noteId = note.Id;

            var userNote = new UserNote {
                UserId = userId, NoteId = noteId, BookId = bookId
            };

            _context.UserNotes.Add(userNote);
            await _context.SaveChangesAsync();

            var updatedBook = await _context.Book.FindAsync(bookId);

            updatedBook.UserNotes.Add(userNote);
            await _context.SaveChangesAsync();

            var updatedUser = await _context.User.FindAsync(userId);

            updatedUser.UserNotes.Add(userNote);
            await _context.SaveChangesAsync();

            return(note);
        }
コード例 #13
0
        /// <summary>
        /// Posts a notification that a note was added to a user.
        /// </summary>
        /// <param name="note">The note.</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        public async Task NotifyUserNoteAdded(UserNote note)
        {
            var guild      = _client.GetGuild((ulong)note.Server.DiscordID);
            var getChannel = await GetModerationLogChannelAsync(guild);

            if (!getChannel.IsSuccess)
            {
                return;
            }

            var channel = getChannel.Entity;

            var author = guild.GetUser((ulong)note.Author.DiscordID);

            var eb = _feedback.CreateEmbedBase();

            eb.WithTitle($"Note Added (#{note.ID})");
            eb.WithColor(Color.Gold);

            var notedUser = guild.GetUser((ulong)note.User.DiscordID);

            eb.WithDescription
            (
                $"A note was added to {notedUser.Mention} (ID {notedUser.Id}) by {author.Mention}.\n" +
                $"Contents: {note.Content}"
            );

            await _feedback.SendEmbedAsync(channel, eb.Build());
        }
コード例 #14
0
    /// <summary>
    /// Sets the contents of the given note.
    /// </summary>
    /// <param name="note">The note.</param>
    /// <param name="content">The content.</param>
    /// <param name="ct">The cancellation token in use.</param>
    /// <returns>A modification result which may or may not have succeeded.</returns>
    public async Task <Result> SetNoteContentsAsync
    (
        UserNote note,
        string content,
        CancellationToken ct = default
    )
    {
        content = content.Trim();

        if (content.IsNullOrWhitespace())
        {
            return(new UserError("You must provide some content for the note."));
        }

        if (content.Length > 1024)
        {
            return(new UserError
                   (
                       "The note is too long. It can be at most 1024 characters."
                   ));
        }

        if (note.Content == content)
        {
            return(new UserError("That's already the note's contents."));
        }

        note.Content = content;
        note.NotifyUpdate();

        await _database.SaveChangesAsync(ct);

        return(Result.FromSuccess());
    }
コード例 #15
0
        public IActionResult UpdateNote(string hdid, [FromBody] UserNote note)
        {
            note.UpdatedBy = hdid;
            RequestResult <UserNote> result = this.noteService.UpdateNote(note);

            return(new JsonResult(result));
        }
コード例 #16
0
            /// <summary>
            /// Insert a user note.
            /// </summary>
            /// <param name="serverId">Server (guild) id.</param>
            /// <param name="userId">User id of who this note is for.</param>
            /// <param name="note">Note text.</param>
            public static void Insert(ulong serverId, ulong userId, Note note)
            {
                try {
                    using DatabaseContext database = new DatabaseContext();

                    if (database.UserNotes.AsNoTracking().Any(x => x.ServerId == serverId & x.UserId == userId))
                    {
                        UserNote userNote = database.UserNotes.FirstOrDefault(x => x.ServerId == serverId & x.UserId == userId);
                        userNote.Notes.Add(note);

                        database.UserNotes.Update(userNote);
                    }
                    else
                    {
                        UserNote item = new UserNote {
                            ServerId = serverId,
                            UserId   = userId,
                            Notes    = new List <Note> {
                                note
                            }
                        };

                        database.UserNotes.Add(item);
                    }

                    database.SaveChanges();
                } catch (Exception ex) {
                    LoggingManager.Log.Error(ex);
                }
            }
コード例 #17
0
ファイル: BaseControl.cs プロジェクト: J3057/MobileApp
                public void EmbedIntersectingUserNotes(ref string htmlStream, ref string textStream, List <IUIControl> userNotes)
                {
                    // this will test to see if any notes in the userNotes list intersect
                    // the Y region of our bounding box. If any do, they will be embedded in the htmlStrea
                    // and then removed from the list so other controls don't embed then.

                    RectangleF controlFrame = GetFrame( );

                    // expand the rect by half its width on all sides in case the note falls between two controls
                    float      halfWidth     = (controlFrame.Width / 2);
                    RectangleF expandedFrame = new RectangleF(controlFrame.X - halfWidth, controlFrame.Y - halfWidth,
                                                              controlFrame.Width + halfWidth, controlFrame.Height + halfWidth);

                    RectangleF userNoteFrame;

                    for (int i = userNotes.Count - 1; i >= 0; i--)
                    {
                        UserNote note = (UserNote)userNotes[i];
                        userNoteFrame = note.GetFrame( );

                        // if the user note is within the bounding vertical box of this control, embed it here
                        if (userNoteFrame.Y >= expandedFrame.Y && userNoteFrame.Y <= expandedFrame.Bottom)
                        {
                            note.BuildHTMLContent(ref htmlStream, ref textStream, null);

                            // this note has been placed, so remove it from the list.
                            userNotes.Remove(userNotes[i]);
                        }
                    }
                }
コード例 #18
0
        public async Task <IActionResult> CreateUserNote([FromRoute] ulong guildId, [FromBody] UserNoteForUpdateDto userNote)
        {
            await RequirePermission(guildId, DiscordPermission.Moderator);

            UserNote createdUserNote = await UserNoteRepository.CreateDefault(_serviceProvider, await GetIdentity()).CreateOrUpdateUserNote(guildId, userNote.UserId, userNote.Description);

            return(StatusCode(201, new UserNoteView(createdUserNote)));
        }
コード例 #19
0
            private async Task ReturnsUnsuccessfulIfNoteDoesNotExist()
            {
                var note = new UserNote(new Server(0), new User(0), new User(1), "Dummy thicc");

                var result = await this.Notes.DeleteNoteAsync(note);

                Assert.False(result.IsSuccess);
            }
コード例 #20
0
ファイル: AlcanceController.cs プロジェクト: Para-dox/OPDB
        public ActionResult VerNota(int id)
        {
            if (User.Identity.IsAuthenticated)
            {
                UserNote userNote = db.UserNotes.Find(id);

                if ((Int32.Parse(User.Identity.Name.Split(',')[0]) == userNote.UserID || Int32.Parse(User.Identity.Name.Split(',')[1]) == 1 || Int32.Parse(User.Identity.Name.Split(',')[0]) == userNote.SubjectID) && Boolean.Parse(User.Identity.Name.Split(',')[2]))
                {
                    UserViewModel userViewModel = new UserViewModel
                    {
                        Note           = userNote,
                        OutreachEntity = db.OutreachEntityDetails.FirstOrDefault(u => u.UserID == userNote.SubjectID)
                    };

                    var user = db.Users.Find(userNote.UserID);

                    if (user.UserTypeID != 3)
                    {
                        var userDetail = db.UserDetails.FirstOrDefault(u => u.UserID == user.UserID);

                        if (userDetail.MiddleInitial != null)
                        {
                            userViewModel.Sender = userDetail.FirstName + " " + userDetail.MiddleInitial + " " + userDetail.LastName;
                        }
                        else
                        {
                            userViewModel.Sender = userDetail.FirstName + " " + userDetail.LastName;
                        }
                    }
                    else
                    {
                        var outreachEntity = db.OutreachEntityDetails.FirstOrDefault(u => u.UserID == user.UserID);
                        userViewModel.Sender = outreachEntity.OutreachEntityName;
                    }

                    if (Int32.Parse(User.Identity.Name.Split(',')[0]) == userNote.SubjectID && !userNote.IsRead)
                    {
                        userViewModel.Note.IsRead = true;
                        db.Entry(userNote).CurrentValues.SetValues(userViewModel.Note);
                        db.SaveChanges();
                    }

                    if ((Int32.Parse(User.Identity.Name.Split(',')[0]) == userNote.UserID || (Int32.Parse(User.Identity.Name.Split(',')[1]) == 1 && Int32.Parse(User.Identity.Name.Split(',')[0]) != userNote.SubjectID)) && Boolean.Parse(User.Identity.Name.Split(',')[2]))
                    {
                        userViewModel.Reader = "Emisor";
                    }

                    else if (Int32.Parse(User.Identity.Name.Split(',')[0]) == userNote.SubjectID && Boolean.Parse(User.Identity.Name.Split(',')[2]))
                    {
                        userViewModel.Reader = "Receptor";
                    }

                    return(PartialView("VerNota", userViewModel));
                }
            }

            return(RedirectToAction("AccesoDenegado", "Home"));
        }
コード例 #21
0
 public IActionResult Edit(UserNote note)
 {
     if (ModelState.IsValid)
     {
         repository.Save(note);
         return(RedirectToAction("Index"));
     }
     return(View(note));
 }
コード例 #22
0
 public UserNoteView(UserNote userNote)
 {
     Id          = userNote.Id;
     GuildId     = userNote.GuildId.ToString();
     UserId      = userNote.UserId.ToString();
     Description = userNote.Description;
     CreatorId   = userNote.CreatorId.ToString();
     UpdatedAt   = userNote.UpdatedAt;
 }
コード例 #23
0
ファイル: Note.cs プロジェクト: J3057/MobileApp
                void UserNoteChanged(UserNote note)
                {
                    // our handler for ANY user note modification. This allows us to notify the
                    // parent UI so it can resize or do whatever it may need to do. (Like grow the
                    // scroll view as the note enlarges)
                    Rock.Mobile.Util.Debug.WriteLine("User Note did change in some way.");

                    OnNoteSizeChanging( );
                }
コード例 #24
0
        /// <summary>
        /// Creates a note for the given user.
        /// </summary>
        /// <param name="authorUser">The author of the note.</param>
        /// <param name="guildUser">The user.</param>
        /// <param name="content">The content of the note.</param>
        /// <returns>A creation result which may or may not have succeeded.</returns>
        public async Task <CreateEntityResult <UserNote> > CreateNoteAsync
        (
            IUser authorUser,
            IGuildUser guildUser,
            string content
        )
        {
            var getServer = await _servers.GetOrRegisterServerAsync(guildUser.Guild);

            if (!getServer.IsSuccess)
            {
                return(CreateEntityResult <UserNote> .FromError(getServer));
            }

            var server = getServer.Entity;

            var getUser = await _users.GetOrRegisterUserAsync(guildUser);

            if (!getUser.IsSuccess)
            {
                return(CreateEntityResult <UserNote> .FromError(getUser));
            }

            var user = getUser.Entity;

            var getAuthor = await _users.GetOrRegisterUserAsync(authorUser);

            if (!getAuthor.IsSuccess)
            {
                return(CreateEntityResult <UserNote> .FromError(getAuthor));
            }

            var author = getAuthor.Entity;

            var note = new UserNote(server, user, author, string.Empty);

            var setContent = await SetNoteContentsAsync(note, content);

            if (!setContent.IsSuccess)
            {
                return(CreateEntityResult <UserNote> .FromError(setContent));
            }

            _database.UserNotes.Update(note);

            await _database.SaveChangesAsync();

            // Requery the database
            var getNote = await GetNoteAsync(guildUser.Guild, note.ID);

            if (!getNote.IsSuccess)
            {
                return(CreateEntityResult <UserNote> .FromError(getNote));
            }

            return(CreateEntityResult <UserNote> .FromSuccess(getNote.Entity));
        }
コード例 #25
0
        public async Task <UserNote> CreateNote(UserNote note)
        {
            using (var connection = GetDbconnection())
            {
                await connection.ExecuteAsync(InsNote, new { note });

                return(note);
            }
        }
コード例 #26
0
        private async void OnReviewClicked(object sender, RoutedEventArgs e)
        {
            // The review page might have to set navigation data (review includes UserStatus). Let's make 100% sure
            // that the database has correct navigation data set up. Hint: it really should already because if we are
            // here, then the book has been set to "reading", and that should in turn force navigation data.
            var bookdb = BookDataContext.Get();

            EnsureBookNavigationData(bookdb);

            var sh = new ContentDialog()
            {
                Title             = "Review Book",
                PrimaryButtonText = "OK",
            };
            // Old style: var review = new BookReview(); // This is the edit control, not the UserReview data
            var review = new ReviewNoteStatusControl(); // This is the edit control, not the UserReview data

            // Set up the potential note, if that's what the user is going to do.
            var    location      = GetCurrBookLocation().ToJson();
            string currSelection = "";

            if (CurrHtml != null && CurrHtml.Contains("DoGetSelection"))
            {
                currSelection = await uiHtml.InvokeScriptAsync("DoGetSelection", null);
            }
            var note = new UserNote()
            {
                BookId     = BookData.BookId,
                CreateDate = DateTimeOffset.Now,
                Location   = location,
                Text       = currSelection,
            };

            review.SetupNote(note);


            sh.Content = review;
            string defaultReviewText = "";

            if (CurrHtml != null && CurrHtml.Contains("DoGetSelection"))
            {
                defaultReviewText = await uiHtml.InvokeScriptAsync("DoGetSelection", null);
            }
            review.SetBookData(BookData, defaultReviewText);
            var result = await sh.ShowAsync();

            switch (result)
            {
            case ContentDialogResult.Primary:
                review.SaveData();
                var nav = Navigator.Get();
                nav.UpdateProjectRome(ControlId, GetCurrBookLocation());
                break;
            }
            SetReviewSymbol();
        }
コード例 #27
0
        public void Delete(UserNote note)
        {
            if (note == null)
            {
                return;
            }

            db.Notes.Remove(note);
            db.SaveChanges();
        }
コード例 #28
0
        public IActionResult DeleteNote([FromBody] UserNote note)
        {
            // Validate the hdid to be a patient.
            ClaimsPrincipal user     = this.httpContextAccessor.HttpContext.User;
            string          userHdid = user.FindFirst("hdid").Value;

            RequestResult <UserNote> result = this.noteService.DeleteNote(note);

            return(new JsonResult(result));
        }
コード例 #29
0
        public IActionResult UpdateNote([FromBody] UserNote note)
        {
            ClaimsPrincipal user     = this.httpContextAccessor.HttpContext.User;
            string          userHdid = user.FindFirst("hdid").Value;

            note.UpdatedBy = userHdid;
            RequestResult <UserNote> result = this.noteService.UpdateNote(note);

            return(new JsonResult(result));
        }
コード例 #30
0
        public IActionResult Delete(string id)
        {
            UserNote note = repository.Notes.FirstOrDefault(n => n.Id == Convert.ToInt32(id));

            if (note != null)
            {
                repository.Delete(note);
            }
            return(RedirectToAction("Index"));
        }
コード例 #31
0
ファイル: CallBackMediator.cs プロジェクト: abel/sinan
        void ExecuteNote(UserNote<UserSession> note)
        {
            if (note.Body == null)
                return;
            //取用户ID,将命令传回给用户
            string sid = note.Body[0].ToString();

            //查找用户:
            UserSession gmClient;
            if (SessionManager<UserSession>.TryGetValue(sid, out gmClient))
            {
                note.Body[0] = note.Session.UserID;
                gmClient.Call(note.Name, note.Body);
            }
        }
コード例 #32
0
ファイル: RountMediator.cs プロジェクト: abel/sinan
        void ExecuteNote(UserNote<UserSession> note)
        {
            if (note.Body == null)
                return;

            //取服务器ID,将命令发到游戏服务器
            IList sid = note.Body[0] as IList;
            note.Body[0] = note.Session.UserID;
            foreach (string key in sid)
            {
                //查找服务器:
                //Console.WriteLine("Name:" + note.Name + ",sid:" + key);
                UserSession server;
                if (SessionManager<UserSession>.TryGetValue(key, out server))
                {
                    server.Call(note.Name, note.Body);
                }
                else
                {
                    Console.WriteLine("没有启动:" + key);
                }
            }
        }
コード例 #33
0
ファイル: DataService.cs プロジェクト: jasona/TexasViking
        public SaveResult DeleteUserNote(UserNote note)
        {
            SaveResult result = new SaveResult { WasSuccessful = true };

            db.UserNotes.DeleteObject(note);

            if (!SaveChanges())
            {
                result.WasSuccessful = false;
                result.Message = "Error deleting UserNote";
            }

            return result;
        }
コード例 #34
0
ファイル: DataService.cs プロジェクト: jasona/TexasViking
        public SaveResult UpdateUserNote(UserNote note)
        {
            SaveResult result = new SaveResult { WasSuccessful = true };

            db.UserNotes.Attach(note);

            db.ObjectStateManager.ChangeObjectState(note, System.Data.EntityState.Modified);

            if (!SaveChanges())
            {
                result.WasSuccessful = false;
                result.Message = "Error updating UserNote";
            }

            return result;
        }
コード例 #35
0
ファイル: DataService.cs プロジェクト: jasona/TexasViking
        public UserNote CreateUserNote(UserNote note)
        {
            db.UserNotes.AddObject(note);

            SaveChanges();

            return note;
        }