示例#1
0
        /// <summary>
        /// obtains the name of class
        /// </summary>
        /// <param name="template">templates name</param>
        /// <returns>returns a name of class</returns>
        private string GetNameType(string template)
        {
            List <Template> templates          = new List <Template>();
            InfoCache <List <Template> > cache = new InfoCache <List <Domain.Entities.Template> >(this.context)
            {
                TimeOut = 120
            };

            Domain.Entities.Template temp;



            TemplateRepository objtemplate = new TemplateRepository(this.session);

            templates = objtemplate.GetAll();
            cache.SetCache("templates", templates);


            temp = templates.Find(t => t.TemplateId == template);

            if (temp != null)
            {
                return(temp.Nameclass);
            }
            else
            {
                return(null);
            }
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LanguageManagement"/> class
        /// </summary>
        /// <param name="session">framework that establishes communication between the application and the database</param>
        /// <param name="context">HTTP context</param>
        public LanguageManagement(ISession session, HttpContextBase context)
        {
            this.session = session;
            this.context = context;

            InfoCache <List <Language> > lang = new InfoCache <List <Language> >(context);

            this.colllang = lang.GetCache("languages");

            if (this.colllang == null || this.colllang.Any().Equals(0))
            {
                LanguageRepository langrepo = new LanguageRepository(session);
                this.colllang = langrepo.GetAll();

                lang.SetCache("languages", this.colllang);
            }
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FrontEndManagement"/> class
        /// </summary>
        /// <param name="session">framework that establishes communication between the application and the database</param>
        /// <param name="context">HTTP Context</param>
        /// <param name="type">Type of front end object</param>
        /// <param name="language">language of thread</param>
        public FrontEndManagement(ISession session, HttpContextBase context, Type type, Language language)
        {
            this.session  = session;
            this.context  = context;
            this.language = language;
            this.type     = type;

            SectionRepository objsec = new SectionRepository(session);

            this.sections = new List <Section>();
            InfoCache <List <Section> > cache = new InfoCache <List <Section> >(context)
            {
                TimeOut = 120
            };

            this.sections = cache.GetCache("sectionsactive");

            if (this.sections == null)
            {
                objsec.Entity.Active = true;
                this.sections        = objsec.GetAll();
                cache.SetCache("sectionsactive", this.sections);
            }
        }
示例#4
0
        /// <summary>
        /// inserts or updates a section object
        /// </summary>
        /// <param name="objSection">object section</param>
        /// <returns>returns true if operation successful</returns>
        public bool SaveSection(Section objSection)
        {
            try
            {
                SectionRepository sectionRepository = new SectionRepository(this.session);

                string section = objSection.Name;

                sectionRepository.Entity = objSection;
                if (sectionRepository.Entity.SectionId != null)
                {
                    if (null != objSection.OldOrder && objSection.Sectionorder != null && objSection.Sectionorder != objSection.OldOrder)
                    {
                        sectionRepository.ChangeOrder(sectionRepository.Entity.Sectionorder.Value, objSection.OldOrder.Value);
                    }

                    sectionRepository.Update();

                    FriendlyurlRepository friendlyrepo = new FriendlyurlRepository(this.session);
                    friendlyrepo.Entity.Id            = sectionRepository.Entity.SectionId;
                    friendlyrepo.Entity.Friendlyurlid = sectionRepository.Entity.Friendlyname;
                    friendlyrepo.Entity.Type          = Friendlyurl.FriendlyType.Section;
                    friendlyrepo.Update();

                    InfoCache <List <Section> > cache = new InfoCache <List <Section> >(this.context)
                    {
                        TimeOut = 120
                    };
                    sectionRepository.Entity = new Section();
                    cache.SetCache("sections", sectionRepository.GetAll());

                    Utils.InsertAudit(
                        this.session,
                        new Audit()
                    {
                        Auditaction = "Update",
                        Description = "Section -> " + section,
                        Joindate    = DateTime.Now,
                        Username    = (this.context.User as CustomPrincipal).UserId
                    });
                }
                else
                {
                    sectionRepository.Entity.Sectionorder = sectionRepository.GetMaxOrder();
                    sectionRepository.Entity.Friendlyname = Utils.GetFindFrienlyName(
                        this.session,
                        sectionRepository.Entity.Name,
                        sectionRepository.Entity.Sectionorder.Value);
                    sectionRepository.Entity.SectionId = Convert.ToInt32(sectionRepository.Insert());

                    FriendlyurlRepository friendlyrepo = new FriendlyurlRepository(this.session);
                    friendlyrepo.Entity.Id            = sectionRepository.Entity.SectionId;
                    friendlyrepo.Entity.Friendlyurlid = sectionRepository.Entity.Friendlyname;
                    friendlyrepo.Entity.Type          = Friendlyurl.FriendlyType.Section;
                    friendlyrepo.Entity.LanguageId    = sectionRepository.Entity.LanguageId;
                    friendlyrepo.Insert();

                    Utils.InsertAudit(
                        this.session,
                        new Audit()
                    {
                        Auditaction = "Insert",
                        Description = "Section -> " + section,
                        Joindate    = DateTime.Now,
                        Username    = (this.context.User as CustomPrincipal).UserId
                    });
                }

                return(true);
            }
            catch (Exception ex)
            {
                Utils.InsertLog(
                    this.session,
                    "Insert Section",
                    ex.Message + " - " + ex.StackTrace);
                return(false);
            }
        }