예제 #1
0
파일: LookUpLogic.cs 프로젝트: HAMANZ/LMJ
        public GeneralContents <T> GetContent <T>(AdminTables table, string langCode, int offset, int limit, List <string> fields, bool isAll, long?LookUpId)
        {
            GeneralContents <T> contents = new GeneralContents <T>();

            LookUpAttributes        main       = new LookUpAttributes();
            Language                lang       = new Language();
            List <LookUpAttributes> attributes = new List <LookUpAttributes>();

            try
            {
                string XMLPath = ConfigurationManager.AppSettings["XMLPath"]; // @"~\LookUp.xml";

                lang = _LanguageAccessor.Get(langCode);

                //Get class's attributes

                attributes = Tools.GetAttributes(table.ToString(), XMLPath);
                //Get main attribute
                main = attributes
                       .Where(e => e.isMain == true)
                       .FirstOrDefault();

                int total = 0;
                if (main == null)
                {
                    main      = new LookUpAttributes();
                    main.Code = "This is any text";
                }

                /* contents = GetMono<T>(table, lang.Id, main.Code);*/
                if (attributes.Count != 0)
                {
                    contents.Contents = ReturnListOf <T>(table, lang.Id, offset, limit, attributes, main, fields, isAll, out total, LookUpId);
                }
                contents.TotalContent = total;
            }
            catch (Exception ex)
            {
                throw;
            }
            return(contents);
        }
예제 #2
0
파일: LookUpLogic.cs 프로젝트: HAMANZ/LMJ
        public List <LookUpAttributes> GetAttributes(AdminTables table, string langCode)
        {
            LookUpAttributes        main       = new LookUpAttributes();
            Language                lang       = new Language();
            List <LookUpAttributes> attributes = new List <LookUpAttributes>();

            try
            {
                string XMLPath = ConfigurationManager.AppSettings["XMLPath"]; // @"~\LookUp.xml";

                lang = _LanguageAccessor.Get(langCode);

                //Get class's attributes

                attributes = Tools.GetAttributes(table.ToString(), XMLPath);

                return(attributes);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
예제 #3
0
파일: LookUpLogic.cs 프로젝트: HAMANZ/LMJ
        public long AddContent <T>(T obj, AdminTables table)
        {
            string XMLPath = ConfigurationManager.AppSettings["XMLPath"];

            //string xmlPath = @"C:\Users\huda\Desktop\Anzimaty\Anz.LMJ\Anz.LMJ.StartUp\LookUp.xml";
            string multiLangValue;
            string imageValue;

            LookUpMedia img = new LookUpMedia();

            List <string> imageValues = new List <string>();


            List <LookUpAttributes> attributes = Tools.GetAttributes(table.ToString(), XMLPath);


            var t = typeof(T);


            LookUp lk = new LookUp();
            LookUpMultiLanguage ml = new LookUpMultiLanguage();
            long parentId          = 0;
            bool isFirst           = true;

            foreach (LookUpAttributes att in attributes)
            {
                lk = new LookUp();

                lk.TableId     = (int)__SharedTableIds[table];
                lk.SysDate     = DateTime.Now;
                lk.UserId      = 1;
                lk.IsDeleted   = false;
                lk.Code        = att.Code;
                lk.isPublished = true;


                if (isFirst)
                {
                    lk.ParentId = null;
                }
                else
                {
                    lk.ParentId = parentId;
                }

                lk = _LookUpAccessor.Add(lk);

                if (isFirst)
                {
                    isFirst  = false;
                    parentId = lk.Id;
                }


                if (att.isMedia)
                {
                    //check if the property is list
                    if (att.isList)
                    {
                        imageValues = (List <string>)(t.GetProperty(att.Name).GetValue(obj));

                        foreach (string s in imageValues)
                        {
                            // add media
                            img = new LookUpMedia();

                            img.isActive  = true;
                            img.isDeleted = false;
                            img.isVideo   = att.isVideo;
                            img.LookUpId  = lk.Id;;
                            img.SysDate   = DateTime.Now;
                            img.Name      = s;


                            _MediaAccessor.Add(img);
                        }
                    }
                    else
                    {
                        imageValue = (string)(t.GetProperty(att.Name).GetValue(obj));

                        img = new LookUpMedia();

                        img.isActive  = true;
                        img.isDeleted = false;
                        img.isVideo   = att.isVideo;
                        img.LookUpId  = lk.Id;
                        img.SysDate   = DateTime.Now;
                        img.Name      = imageValue;


                        _MediaAccessor.Add(img);
                    }
                }
                else
                {
                    // add lookupmulti

                    multiLangValue = (t.GetProperty(att.Name).GetValue(obj)).ToString();

                    ml = new LookUpMultiLanguage();

                    ml.LookUpId = lk.Id;
                    if (att.isLangNull)
                    {
                        ml.LangId = null;
                    }
                    else
                    {
                        ml.LangId = 1;
                    }

                    ml.SysDate   = DateTime.Now;
                    ml.isDeleted = false;
                    //ml.UserId = 1;
                    ml.Description = multiLangValue;
                    // ml.isPublished = true;

                    _LookUpMultiAccessor.Add(ml);
                }
            }
            return(parentId);
        }