public async Task <ActionResult> CommentEdit_Partial(EditModel model)
        {
            await model.UpdateDataAsync();

            using (BlogCommentDataProvider dataProvider = new BlogCommentDataProvider(model.EntryIdentity)) {
                BlogComment data = await dataProvider.GetItemAsync(model.Identity);

                if (data == null)
                {
                    throw new Error(this.__ResStr("alreadyDeleted", "The comment entry with id {0} has been removed and can no longer be updated", model.Identity));
                }
                if (!ModelState.IsValid)
                {
                    return(PartialView(model));
                }

                // save updated item
                data = model.GetData(data); // merge new data into original
                await model.SetData(data);  // and all the data back into model for final display

                switch (await dataProvider.UpdateItemAsync(data))
                {
                default:
                case UpdateStatusEnum.RecordDeleted:
                    throw new Error(this.__ResStr("alreadyDeleted", "The comment entry with id {0} has been removed and can no longer be updated", model.Identity));

                case UpdateStatusEnum.NewKeyExists:
                    throw new Error(this.__ResStr("alreadyExists", "A comment with id {0} already exists.", model.Identity));

                case UpdateStatusEnum.OK:
                    break;
                }
                return(FormProcessed(model, this.__ResStr("okSaved", "Comment saved")));
            }
        }
        public async Task <ActionResult> Remove(int blogEntry, int comment)
        {
            using (BlogCommentDataProvider dataProvider = new BlogCommentDataProvider(blogEntry)) {
                BlogComment cmt = await dataProvider.GetItemAsync(comment);

                if (cmt == null)
                {
                    throw new InternalError("Can't find comment entry {0}", comment);
                }
                if (!await dataProvider.RemoveItemAsync(comment))
                {
                    throw new InternalError("Can't remove comment entry");
                }
                return(Reload(null, Reload: ReloadEnum.Page));
            }
        }
        public async Task <ActionResult> CommentEdit(int blogEntry, int comment)
        {
            using (BlogCommentDataProvider dataProvider = new BlogCommentDataProvider(blogEntry)) {
                EditModel model  = new EditModel {
                };
                BlogComment data = await dataProvider.GetItemAsync(comment);

                if (data == null)
                {
                    throw new Error(this.__ResStr("notFound", "Comment entry with id {0} not found."), comment);
                }
                await model.SetData(data);

                Module.Title = data.Title;
                return(View(model));
            }
        }
        public async Task <ActionResult> Approve(int blogEntry, int comment)
        {
            using (BlogCommentDataProvider dataProvider = new BlogCommentDataProvider(blogEntry)) {
                BlogComment cmt = await dataProvider.GetItemAsync(comment);

                if (cmt == null)
                {
                    throw new InternalError("Can't find comment entry {0}", comment);
                }
                cmt.Approved = true;
                UpdateStatusEnum status = await dataProvider.UpdateItemAsync(cmt);

                if (status != UpdateStatusEnum.OK)
                {
                    throw new InternalError("Can't update comment entry - {0}", status);
                }
                return(Reload(null, Reload: ReloadEnum.Page));
            }
        }