Пример #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 void DeleteFaq(Faq faq)
        {
            //Cancella la FAQ specificata
            ITransaction tx;

            tx = this.Session_Col.BeginTransaction();
            this.Session_Col.Delete(faq);
            tx.Commit();
        }
Пример #3
0
        public void AddFaq(Faq Faq)
        {
            ITransaction tx;

            tx = this.Session_Col.BeginTransaction();
            this.Session_Col.Save(Faq);
            tx.Commit();
            //Aggiorna una Faq.
            //Verranno modificati sia i dati relativi alla FAQ
            //che l'associazione con le categorie
        }
Пример #4
0
        public void DeleteFaq(Int64 FaqID)
        {
            //Cancella la FAQ specificata
            ITransaction tx;

            tx = this.Session_Col.BeginTransaction();
            Faq faq = (from Faq fq
                       in this.Session_Col.Linq <Faq>()
                       where fq.Id == FaqID
                       select fq).First();

            this.Session_Col.Delete(faq);
            tx.Commit();
        }
Пример #5
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);
        }
Пример #6
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);
        }
Пример #7
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);
        }
Пример #8
0
        public Faq GetFaq(Int64 FaqId, Int32 CommunityID)
        {
            Faq Faq = new Faq();

            try
            {
                Faq = (
                    from Faq faq
                    in this.Session_Col.Linq <Faq>()
                    where faq.Id == FaqId && faq.CommunityId == CommunityID
                    orderby faq.Order, faq.Id
                    select faq
                    ).First();
            }
            catch {
                Faq.Id       = -1;
                Faq.Answer   = "";
                Faq.Question = "";
            }

            return(Faq);
        }
Пример #9
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);
        }
Пример #10
0
        public Enum.ErrorCode UpdateFaq(Int64 Id, String Question, String Answer)
        {
            Enum.ErrorCode ErrorCode = Enum.ErrorCode.none;

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

                Manager.SaveOrUpdate <Faq>(Faq);

                //FAQ_Dal.UpdateFaq(Faq);
            }

            return(ErrorCode);
        }
Пример #11
0
 public void DeleteFaq(Faq faq)
 {
     FAQ_Dal.DeleteFaq(faq);
 }
Пример #12
0
 public Link(Faq Faq, Category Category)
 {
     this.Id = new IdLink(Faq, Category);
 }
Пример #13
0
 public IdLink(Faq Faq, Category Category)
 {
     this.Faq      = Faq;
     this.Category = Category;
 }