public override void DeleteDraft(string chapterVersionId, bool deleteAll, string draftId, string newChapterVersionId)
        {
            try
            {
                using (TransactionScope transaction = new TransactionScope(mConfiguration))
                {
                    DraftDataStore dataStore = new DraftDataStore(transaction);

                    //items are returned in sorted order - Sorted by SaveDate desc.
                    //delete only one record
                    if (!deleteAll)
                    {
                        if (!string.IsNullOrEmpty(draftId))
                        {
                            Draft draft = new Draft();
                            draft = dataStore.FindItemByDraftId(draftId).First(x => x.Id.Equals(draftId));

                            draft.Deleted = true;
                            dataStore.Update(draft);
                        }

                        //update previous drafts if any

                        IList <Draft> drafts = dataStore.FindItemByChapterId(chapterVersionId);
                        if (drafts.Count > 0)
                        {
                            foreach (Draft item in drafts)
                            {
                                item.VersionId = newChapterVersionId;
                                dataStore.Update(item);
                            }
                        }
                    }
                    //delete all previous records.
                    else
                    {
                        IList <Draft> drafts = dataStore.FindItemByChapterId(chapterVersionId);

                        if (drafts.Count > 0)
                        {
                            foreach (Draft item in drafts)
                            {
                                if (!string.IsNullOrEmpty(newChapterVersionId))
                                {
                                    if (item.Id != draftId)
                                    {
                                        item.Deleted = true;
                                        dataStore.Update(item);
                                    }
                                }
                                else
                                {
                                    item.Deleted = true;
                                    dataStore.Update(item);
                                }
                            }
                        }
                    }
                    transaction.Commit();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
 public static Draft UpsertDraft(Draft draft)
 {
     return(Provider.UpsertDraft(draft));
 }
Esempio n. 3
0
 public abstract Draft UpsertDraft(Draft draft);