예제 #1
0
        //public FAQService(iDataContext oDC)
        //{
        //    DC = oDC;
        //    //this.Manager = new BaseManager(oDC);
        //    FAQ_Dal = new FAQDal(ComolSession);
        //    this.UC = null;
        //}

        #endregion

        #region Read
        //Per Web Service

        /// <summary>
        /// Recupera una singola FAQ, controllando la comunità.
        /// </summary>
        /// <param name="FaqId">L'ID della FAQ da recuperare</param>
        /// <returns>La FAQ o una FAQ VUOTA se non viene trovata.</returns>
        public DTO_Faq GetFaq(Int64 FaqId)
        {
            Faq SourceFaq = FAQ_Dal.GetFaq(FaqId, UC.CurrentCommunityID);

            DTO_Faq outFaq = new DTO_Faq();

            //CurrentContext.UserContext.CurrentCommunityID
            if (SourceFaq != null) // && SourceFaq.CommunityId == UC.CurrentCommunityID)
            {
                outFaq.ID       = SourceFaq.Id;
                outFaq.Question = SourceFaq.Question;
                outFaq.Answer   = SourceFaq.Answer;

                outFaq.Categories = new List <DTO_Category>();

                if (SourceFaq.onCategories != null && SourceFaq.onCategories.Count() > 0)
                {
                    foreach (Category Cat in SourceFaq.onCategories)
                    {
                        outFaq.Categories.Add(new DTO_Category()
                        {
                            Name = Cat.Name, ID = Cat.Id
                        });
                    }
                }
            }
            //else
            //{
            //    outFaq.Categories = new List<String>();
            //}

            return(outFaq);
        }
예제 #2
0
        public Enum.ErrorCode DeleteCategory(Int32 CommunityId, Int64 CategoryId)
        {
            Category Cat = FAQ_Dal.GetCategory(CommunityId, CategoryId);

            if (Cat != null)
            {
                //FAQ_Dal.DeleteFaqOnCategory(CategoryId);
                //Cat.Faqs = FAQ_Dal.GetFaqs(CommunityId, CategoryId);

                //if (Cat.Faqs.Count > 0)
                //{
                //    return Enum.ErrorCode.CategoryWithFaq;
                //}
                //else
                //{
                FAQ_Dal.DeleteCategory(Cat);
                //    FAQ_Dal.DeleteOrphanFaq(CategoryId);
                //}
            }
            else
            {
                return(Enum.ErrorCode.NoData);
            }

            return(Enum.ErrorCode.none);
        }
예제 #3
0
        public EditFaqModel GetEditFaqModel(Int64 FaqId, Int32 CommunityId)
        {
            EditFaqModel EFM = new EditFaqModel();

            EFM.Faq      = FAQ_Dal.GetFaq(FaqId, CommunityId);
            EFM.Category = FAQ_Dal.GetCategoriesList(CommunityId);
            return(EFM);
        }
예제 #4
0
        public void CreateCategory(Category Category)
        {
            Person user = Manager.Get <Person>(UC.CurrentUserID);

            Category.CreateMetaInfo(user, UC.IpAddress, UC.ProxyIpAddress);

            FAQ_Dal.AddCategory(Category);
        }
예제 #5
0
        public UserDataModel GetUserDataModel(Int32 CommunityId)
        {
            UserDataModel UDM = new UserDataModel();

            UDM.Faqs     = FAQ_Dal.GetFaqs(CommunityId);
            UDM.Category = FAQ_Dal.GetCategoriesList(CommunityId);
            UDM.Category.Add(DefaultCategory());
            UDM.CurrentCategory = DefaultCategory();
            return(UDM);
        }
예제 #6
0
        public void UpdateCategory(Int64 CategoryId, String CategoryName, Int32 CommunityId)
        {
            Category cat = FAQ_Dal.GetCategory(CommunityId, CategoryId);

            cat.Name = CategoryName;

            Person user = Manager.Get <Person>(UC.CurrentUserID);

            cat.UpdateMetaInfo(user, UC.IpAddress, UC.ProxyIpAddress);

            FAQ_Dal.UpdateCategory(cat);
        }
예제 #7
0
        public EditCategoryModel GetEditCategoryModel(Int32 CommunityId)
        {
            EditCategoryModel ECM = new EditCategoryModel();

            ECM.Categories = FAQ_Dal.GetCategoriesList(CommunityId);

            foreach (Category cat in ECM.Categories)
            {
                cat.Elements = (from Faq faq in FAQ_Dal.GetFaqs(CommunityId, cat.Id) select faq).Count();
            }

            return(ECM);
        }
예제 #8
0
        public EditFaqModel GetNewFaqModel(Int32 CommunityId)
        {
            EditFaqModel EFM    = new EditFaqModel();
            Faq          NewFaq = new Faq();

            NewFaq.Question     = "";
            NewFaq.Answer       = "";
            NewFaq.CommunityId  = CommunityId;
            NewFaq.onCategories = new List <Category>();
            EFM.Faq             = NewFaq;

            EFM.Category = FAQ_Dal.GetCategoriesList(CommunityId);
            //EFM.Faq = FAQ_Dal.GetFaq(FaqId);
            //EFM.Category = FAQ_Dal.GetCategoriesList(CommunityId);
            return(EFM);
        }
예제 #9
0
        /// <summary>
        /// Utilizzato sia per modificare Domanda/risposta
        /// che per aggiornare la lista di categorie associate.
        /// </summary>
        /// <param name="Faq"></param>
        /// <remarks>
        /// Verificare la struttura in relazione ad nHibernate, Id ed affini...
        /// </remarks>
        public Enum.ErrorCode UpdateFaq(Faq Faq)
        {
            Enum.ErrorCode ErrorCode = Enum.ErrorCode.none;
            if (Faq.onCategories.Count > 0)
            {
                Person user = Manager.Get <Person>(UC.CurrentUserID);
                Faq.UpdateMetaInfo(user, UC.IpAddress, UC.ProxyIpAddress);


                FAQ_Dal.UpdateFaq(Faq);
            }
            else
            {
                ErrorCode = Enum.ErrorCode.NoCategory;
            }

            return(ErrorCode);
        }
예제 #10
0
        public Enum.ErrorCode CreateCategory(String CategoryName, Int32 CommunityId)
        {
            if (CategoryName == "")
            {
                return(Enum.ErrorCode.NoData);
            }
            else
            {
                Category Cat = new Category();
                Cat.Name        = CategoryName;
                Cat.CommunityId = CommunityId;

                Person user = Manager.Get <Person>(UC.CurrentUserID);
                Cat.UpdateMetaInfo(user, UC.IpAddress, UC.ProxyIpAddress);

                FAQ_Dal.AddCategory(Cat);
                return(Enum.ErrorCode.none);
            }
        }
예제 #11
0
        public Faq CreateFaq(Int32 CommunityId, String Question, String Answer, IList <Int64> CategoriesId)
        {
            Faq newFaq = new Faq();

            newFaq.CommunityId = CommunityId;
            newFaq.Question    = Question;
            newFaq.Answer      = Answer;

            if (CategoriesId.Count > 0)
            {
                newFaq.onCategories = FAQ_Dal.GetCategoriesList(CategoriesId);
            }
            Person user = Manager.Get <Person>(UC.CurrentUserID);

            newFaq.CreateMetaInfo(user, UC.IpAddress, UC.ProxyIpAddress);

            FAQ_Dal.AddFaq(newFaq);
            return(newFaq);
        }
예제 #12
0
        /// <summary>
        /// Recupera l'elenco di categorie disponibili per la comunità corrente
        /// </summary>
        /// <returns>
        ///     L'elenco delle categorie o un elenco vuoto se non ci sono categorie.
        /// </returns>
        public List <DTO_Category> GetCategories()
        {
            List <DTO_Category> OutCats = new List <DTO_Category>();

            IList <Category> srcCats = FAQ_Dal.GetCategoriesList(UC.CurrentCommunityID);

            if (srcCats != null && srcCats.Count() > 0)
            {
                foreach (Category srcCt in srcCats)
                {
                    DTO_Category outCat = new DTO_Category();
                    outCat.ID   = srcCt.Id;
                    outCat.Name = srcCt.Name;
                    OutCats.Add(outCat);
                }
            }

            return(OutCats);
        }
예제 #13
0
        /// <summary>
        /// Recupera l'elenco delle faq disponibili in visualizzazione
        /// </summary>
        /// <param name="CategoryID">La categoria con cui filtrarle. Se minore di 0, vengono recuperate TUTTE le faq di quella comunità</param>
        /// <returns>Una lista di FAQ o una lista vuota se non ci sono FAQ.</returns>
        public List <DTO_Faq> GetFaqList(Int64 CategoryID)
        {
            List <DTO_Faq> OutFaqs = new List <DTO_Faq>();

            IList <Faq> srcFaqs = new List <Faq>();

            if (CategoryID > 0)
            {
                srcFaqs = FAQ_Dal.GetFaqs(UC.CurrentCommunityID, CategoryID);
            }
            else
            {
                srcFaqs = FAQ_Dal.GetFaqs(UC.CurrentCommunityID);
            }

            if (srcFaqs != null && srcFaqs.Count() > 0)
            {
                foreach (Faq fq in srcFaqs)
                {
                    DTO_Faq outfq = new DTO_Faq();
                    outfq.ID       = fq.Id;
                    outfq.Question = fq.Question;
                    outfq.Answer   = fq.Answer;
                    if (fq.onCategories != null && fq.onCategories.Count() > 0)
                    {
                        foreach (Category Cat in fq.onCategories)
                        {
                            outfq.Categories.Add(new DTO_Category()
                            {
                                Name = Cat.Name, ID = Cat.Id
                            });
                        }
                    }
                    OutFaqs.Add(outfq);
                }
            }

            return(OutFaqs);
        }
예제 #14
0
        public Enum.ErrorCode UpdateFaq(Int64 Id, String Question, String Answer, IList <Int64> CategoriesId, Int32?Order = null)
        {
            Enum.ErrorCode ErrorCode = Enum.ErrorCode.none;

            if ((Question == null) || (Question == "") || (Answer == null) || (Answer == ""))
            {
                ErrorCode = Enum.ErrorCode.NoData;
            }
            else
            {
                Faq Faq = FAQ_Dal.GetFaq(Id, UC.CurrentCommunityID);
                Faq.Question     = Question;
                Faq.Answer       = Answer;
                Faq.onCategories = FAQ_Dal.GetCategoriesList(CategoriesId);
                Person user = Manager.Get <Person>(UC.CurrentUserID);
                Faq.UpdateMetaInfo(user, UC.IpAddress, UC.ProxyIpAddress);
                Faq.Order = Order;

                FAQ_Dal.UpdateFaq(Faq);
            }

            return(ErrorCode);
        }
예제 #15
0
 public void DeleteFaq(Faq faq)
 {
     FAQ_Dal.DeleteFaq(faq);
 }
예제 #16
0
 public void DeleteFaq(Int64 FaqId)
 {
     FAQ_Dal.DeleteFaq(FaqId);
 }