/// <summary>
        /// This method is used to save category contents with associated category
        /// </summary>
        /// <param name="content"></param>
        public void SaveCategoryContent(ContentModel content)
        {
            using (SDNSettingEntities objCategoryEntities = new SDNSettingEntities())
            {
                var obj = objCategoryEntities.CategoriesContents.Where(x => x.Cat_Id == content.CategoryID && x.IsDeleted != true && x.Set_Default == true && content.IsSelected == true).FirstOrDefault();
                if (obj != null)
                {
                    obj.Set_Default = false;
                    objCategoryEntities.SaveChanges();
                }

                try
                {
                    CategoriesContent catContent = new CategoriesContent();
                    catContent.Cat_Contents  = content.ContentName.Trim();
                    catContent.Content_Limit = content.Limit;
                    catContent.Cat_Id        = content.CategoryID;
                    catContent.IsDeleted     = false;
                    catContent.Set_Default   = content.IsSelected;
                    catContent.CreatedDate   = DateTime.Now;
                    objCategoryEntities.CategoriesContents.Add(catContent);
                    objCategoryEntities.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        /// <summary>
        /// This method is used to update category contents with associated category
        /// </summary>
        /// <param name="content"></param>
        public void UpdateCategoryContent(ContentModel content)
        {
            using (SDNSettingEntities objCategoryEntities = new SDNSettingEntities())
            {
                try
                {
                    var obj = objCategoryEntities.CategoriesContents.Where(x => x.Cat_Id == content.CategoryID && x.IsDeleted != true && x.Set_Default == true && content.IsSelected == true).FirstOrDefault();
                    if (obj != null)
                    {
                        obj.Set_Default = false;
                        objCategoryEntities.SaveChanges();
                    }

                    CategoriesContent catContent = objCategoryEntities.CategoriesContents.SingleOrDefault(i => i.ID == content.ContentID);
                    if (catContent != null)
                    {
                        catContent.Cat_Contents  = content.ContentName;
                        catContent.Content_Limit = content.Limit;
                        catContent.Set_Default   = content.IsSelected;
                        catContent.ModifiedDate  = DateTime.Now;
                        objCategoryEntities.SaveChanges();
                    }

                    //var categoryContent = objCategoryEntities.CategoriesContents.Where(e => e.Cat_Id == content.CategoryID && e.ID!=content.ContentID).ToList();
                    //if (categoryContent != null)
                    //{
                    //    foreach (var c in categoryContent)
                    //    {
                    //        if (content.IsSelected == true)
                    //        {
                    //            if (c.Set_Default == true)
                    //            {
                    //                c.Set_Default = false;
                    //            }
                    //        }
                    //        else
                    //        {
                    //            if(c.Set_Default==true)
                    //            {
                    //                c.Set_Default = true;
                    //            }
                    //        }
                    //        objCategoryEntities.SaveChanges();
                    //    }
                    //}
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        /// <summary>
        /// This method is used to delete Category Content
        /// </summary>
        /// <param name="catId"></param>
        public void DeleteCategoryContent(int contentID)
        {
            using (SDNSettingEntities objCategoryEntities = new SDNSettingEntities())
            {
                try
                {
                    CategoriesContent catContent = objCategoryEntities.CategoriesContents.SingleOrDefault(i => i.ID == contentID);
                    if (catContent != null)
                    {
                        catContent.IsDeleted = true;

                        objCategoryEntities.SaveChanges();
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
예제 #4
0
 public void UpdateCategoriesContent(CategoriesContent categoriesContent)
 {
     _categoriesContents.AddOrUpdate(categoriesContent);
 }
예제 #5
0
 public void InsertCategoriesContent(CategoriesContent categoriesContent)
 {
     _categoriesContents.Add(categoriesContent);
     return;
 }