public List <TVItemUserAuthorizationModel> GetTVItemUserAuthorizationModelListWithTVItemID1DB(int TVItemID1)
        {
            TVItemService tvItemService = new TVItemService(this.LanguageRequest, this.User);

            List <TVItemUserAuthorizationModel> tvItemUserAuthorizationModelList = (from c in db.TVItemUserAuthorizations
                                                                                    let tvItemID1TVText = (from cl in db.TVItemLanguages where cl.Language == (int)LanguageRequest && cl.TVItemID == c.TVItemID1 select cl.TVText).FirstOrDefault <string>()
                                                                                                          let tvItemID2TVText = (from cl in db.TVItemLanguages where cl.Language == (int)LanguageRequest && cl.TVItemID == c.TVItemID2 select cl.TVText).FirstOrDefault <string>()
                                                                                                                                let tvItemID3TVText = (from cl in db.TVItemLanguages where cl.Language == (int)LanguageRequest && cl.TVItemID == c.TVItemID3 select cl.TVText).FirstOrDefault <string>()
                                                                                                                                                      let tvItemID4TVText = (from cl in db.TVItemLanguages where cl.Language == (int)LanguageRequest && cl.TVItemID == c.TVItemID4 select cl.TVText).FirstOrDefault <string>()
                                                                                                                                                                            let tvPath1 = (from ct in db.TVItems where ct.TVItemID == c.TVItemID1 select ct.TVPath).FirstOrDefault <string>()
                                                                                                                                                                                          let tvPath2 = (from ct in db.TVItems where ct.TVItemID == c.TVItemID2 select ct.TVPath).FirstOrDefault <string>()
                                                                                                                                                                                                        let tvPath3 = (from ct in db.TVItems where ct.TVItemID == c.TVItemID3 select ct.TVPath).FirstOrDefault <string>()
                                                                                                                                                                                                                      let tvPath4 = (from ct in db.TVItems where ct.TVItemID == c.TVItemID4 select ct.TVPath).FirstOrDefault <string>()
                                                                                                                                                                                                                                    where c.TVItemID1 == TVItemID1
                                                                                                                                                                                                                                    select new TVItemUserAuthorizationModel
            {
                Error = "",
                TVItemUserAuthorizationID = c.TVItemUserAuthorizationID,
                DBCommand = (DBCommandEnum)c.DBCommand,
                ContactTVItemID = c.ContactTVItemID,
                TVItemID1 = c.TVItemID1,
                TVText1 = tvItemID1TVText,
                TVPath1 = tvPath1,
                TVItemID2 = c.TVItemID2,
                TVText2 = tvItemID2TVText,
                TVPath2 = tvPath2,
                TVItemID3 = c.TVItemID3,
                TVText3 = tvItemID3TVText,
                TVPath3 = tvPath3,
                TVItemID4 = c.TVItemID4,
                TVText4 = tvItemID4TVText,
                TVPath4 = tvPath4,
                TVAuth = (TVAuthEnum)c.TVAuth,
                LastUpdateDate_UTC = c.LastUpdateDate_UTC,
                LastUpdateContactTVItemID = c.LastUpdateContactTVItemID,
            }).ToList <TVItemUserAuthorizationModel>();

            foreach (TVItemUserAuthorizationModel tvItemUserAuthorizationModel in tvItemUserAuthorizationModelList)
            {
                tvItemUserAuthorizationModel.TVLevel1 = tvItemService.GetTVLevel(tvItemUserAuthorizationModel.TVPath1);

                if (tvItemUserAuthorizationModel.TVPath2 != null)
                {
                    tvItemUserAuthorizationModel.TVLevel2 = tvItemService.GetTVLevel(tvItemUserAuthorizationModel.TVPath2);
                }

                if (tvItemUserAuthorizationModel.TVPath3 != null)
                {
                    tvItemUserAuthorizationModel.TVLevel3 = tvItemService.GetTVLevel(tvItemUserAuthorizationModel.TVPath3);
                }

                if (tvItemUserAuthorizationModel.TVPath4 != null)
                {
                    tvItemUserAuthorizationModel.TVLevel4 = tvItemService.GetTVLevel(tvItemUserAuthorizationModel.TVPath4);
                }
            }
            return(tvItemUserAuthorizationModelList.OrderBy(c => c.TVLevel1).ThenBy(c => c.TVLevel2).ToList <TVItemUserAuthorizationModel>());
        }
        public TVTypeUserAuthorizationModel GetTVTypeUserAuthorizationModelWithTVTypeUserAuthorizationIDDB(int TVTypeUserAuthorizationID)
        {
            TVItemService tvItemService = new TVItemService(this.LanguageRequest, this.User);

            TVTypeUserAuthorizationModel tvTypeUserAuthorizationModel = (from c in db.TVTypeUserAuthorizations
                                                                         where c.TVTypeUserAuthorizationID == TVTypeUserAuthorizationID
                                                                         select new TVTypeUserAuthorizationModel
            {
                Error = "",
                TVTypeUserAuthorizationID = c.TVTypeUserAuthorizationID,
                DBCommand = (DBCommandEnum)c.DBCommand,
                ContactTVItemID = c.ContactTVItemID,
                TVType = (TVTypeEnum)c.TVType,
                TVPath = "",
                TVLevel = -1,
                TVAuth = (TVAuthEnum)c.TVAuth,
                LastUpdateDate_UTC = c.LastUpdateDate_UTC,
                LastUpdateContactTVItemID = c.LastUpdateContactTVItemID,
            }).FirstOrDefault <TVTypeUserAuthorizationModel>();

            if (tvTypeUserAuthorizationModel == null)
            {
                return(ReturnError(string.Format(ServiceRes.CouldNotFind_With_Equal_, BaseEnumServiceRes.TVTypeUserAuthorization, BaseEnumServiceRes.TVTypeUserAuthorizationID, TVTypeUserAuthorizationID)));
            }

            tvTypeUserAuthorizationModel.TVPath  = tvTypeNamesAndPathList.Where(c => c.Index == (int)tvTypeUserAuthorizationModel.TVType).FirstOrDefault().TVPath;
            tvTypeUserAuthorizationModel.TVLevel = tvItemService.GetTVLevel(tvTypeUserAuthorizationModel.TVPath);

            return(tvTypeUserAuthorizationModel);
        }
        public List <TVTypeUserAuthorizationModel> GetTVTypeUserAuthorizationModelListWithContactTVItemIDDB(int ContactTVItemID)
        {
            TVItemService tvItemService = new TVItemService(this.LanguageRequest, this.User);

            List <TVTypeUserAuthorizationModel> tvTypeUserAuthorizationModelList = (from c in db.TVTypeUserAuthorizations
                                                                                    where c.ContactTVItemID == ContactTVItemID
                                                                                    select new TVTypeUserAuthorizationModel
            {
                Error = "",
                TVTypeUserAuthorizationID = c.TVTypeUserAuthorizationID,
                DBCommand = (DBCommandEnum)c.DBCommand,
                ContactTVItemID = c.ContactTVItemID,
                TVType = (TVTypeEnum)c.TVType,
                TVPath = "",
                TVLevel = -1,
                TVAuth = (TVAuthEnum)c.TVAuth,
                LastUpdateDate_UTC = c.LastUpdateDate_UTC,
                LastUpdateContactTVItemID = c.LastUpdateContactTVItemID,
            }).ToList <TVTypeUserAuthorizationModel>();

            foreach (TVTypeUserAuthorizationModel tvTypeUserAuthorizationModel in tvTypeUserAuthorizationModelList)
            {
                tvTypeUserAuthorizationModel.TVPath  = tvTypeNamesAndPathList.Where(c => c.Index == (int)tvTypeUserAuthorizationModel.TVType).FirstOrDefault().TVPath;
                tvTypeUserAuthorizationModel.TVLevel = tvItemService.GetTVLevel(tvTypeUserAuthorizationModel.TVPath);
            }

            return(tvTypeUserAuthorizationModelList.OrderBy(c => c.TVLevel).ToList <TVTypeUserAuthorizationModel>());
        }
        public TVItemUserAuthorizationModel GetTVItemUserAuthorizationModelWithContactTVItemIDTVItemID1TVItemID2TVItemID3TVItemID4DB(int ContactTVItemID, int TVItemID1, int?TVItemID2, int?TVItemID3, int?TVItemID4)
        {
            TVItemService tvItemService = new TVItemService(this.LanguageRequest, this.User);

            TVItemUserAuthorizationModel tvItemUserAuthorizationModel = (from c in db.TVItemUserAuthorizations
                                                                         let tvItemID1TVText = (from cl in db.TVItemLanguages where cl.Language == (int)LanguageRequest && cl.TVItemID == c.TVItemID1 select cl.TVText).FirstOrDefault <string>()
                                                                                               let tvItemID2TVText = (from cl in db.TVItemLanguages where cl.Language == (int)LanguageRequest && cl.TVItemID == c.TVItemID2 select cl.TVText).FirstOrDefault <string>()
                                                                                                                     let tvItemID3TVText = (from cl in db.TVItemLanguages where cl.Language == (int)LanguageRequest && cl.TVItemID == c.TVItemID3 select cl.TVText).FirstOrDefault <string>()
                                                                                                                                           let tvItemID4TVText = (from cl in db.TVItemLanguages where cl.Language == (int)LanguageRequest && cl.TVItemID == c.TVItemID4 select cl.TVText).FirstOrDefault <string>()
                                                                                                                                                                 let tvPath1 = (from ct in db.TVItems where ct.TVItemID == c.TVItemID1 select ct.TVPath).FirstOrDefault <string>()
                                                                                                                                                                               let tvPath2 = (from ct in db.TVItems where ct.TVItemID == c.TVItemID2 select ct.TVPath).FirstOrDefault <string>()
                                                                                                                                                                                             let tvPath3 = (from ct in db.TVItems where ct.TVItemID == c.TVItemID3 select ct.TVPath).FirstOrDefault <string>()
                                                                                                                                                                                                           let tvPath4 = (from ct in db.TVItems where ct.TVItemID == c.TVItemID4 select ct.TVPath).FirstOrDefault <string>()
                                                                                                                                                                                                                         where c.ContactTVItemID == ContactTVItemID &&
                                                                                                                                                                                                                         c.TVItemID1 == TVItemID1 &&
                                                                                                                                                                                                                         c.TVItemID2 == TVItemID2 &&
                                                                                                                                                                                                                         c.TVItemID3 == TVItemID3 &&
                                                                                                                                                                                                                         c.TVItemID4 == TVItemID4
                                                                                                                                                                                                                         select new TVItemUserAuthorizationModel
            {
                Error = "",
                TVItemUserAuthorizationID = c.TVItemUserAuthorizationID,
                DBCommand = (DBCommandEnum)c.DBCommand,
                ContactTVItemID = c.ContactTVItemID,
                TVItemID1 = c.TVItemID1,
                TVText1 = tvItemID1TVText,
                TVPath1 = tvPath1,
                TVItemID2 = c.TVItemID2,
                TVText2 = tvItemID2TVText,
                TVPath2 = tvPath2,
                TVItemID3 = c.TVItemID3,
                TVText3 = tvItemID3TVText,
                TVPath3 = tvPath3,
                TVItemID4 = c.TVItemID4,
                TVText4 = tvItemID4TVText,
                TVPath4 = tvPath4,
                TVAuth = (TVAuthEnum)c.TVAuth,
                LastUpdateDate_UTC = c.LastUpdateDate_UTC,
                LastUpdateContactTVItemID = c.LastUpdateContactTVItemID,
            }).FirstOrDefault <TVItemUserAuthorizationModel>();

            if (tvItemUserAuthorizationModel == null)
            {
                return(ReturnError(string.Format(ServiceRes.CouldNotFind_With_Equal_, ServiceRes.TVItemUserAuthorization, ServiceRes.ContactTVItemID
                                                 + "," + ServiceRes.TVItemID1 + ","
                                                 + ServiceRes.TVItemID2 ?? "" + ","
                                                 + ServiceRes.TVItemID3 ?? "" + ","
                                                 + ServiceRes.TVItemID4 ?? "",
                                                 ContactTVItemID.ToString() + ","
                                                 + TVItemID1.ToString() + ","
                                                 + TVItemID2 ?? "" + ","
                                                 + TVItemID3 ?? "" + ","
                                                 + TVItemID4 ?? ""
                                                 )));
            }

            tvItemUserAuthorizationModel.TVLevel1 = tvItemService.GetTVLevel(tvItemUserAuthorizationModel.TVPath1);

            if (tvItemUserAuthorizationModel.TVPath2 != null)
            {
                tvItemUserAuthorizationModel.TVLevel2 = tvItemService.GetTVLevel(tvItemUserAuthorizationModel.TVPath2);
            }

            if (tvItemUserAuthorizationModel.TVPath3 != null)
            {
                tvItemUserAuthorizationModel.TVLevel3 = tvItemService.GetTVLevel(tvItemUserAuthorizationModel.TVPath3);
            }

            if (tvItemUserAuthorizationModel.TVPath4 != null)
            {
                tvItemUserAuthorizationModel.TVLevel4 = tvItemService.GetTVLevel(tvItemUserAuthorizationModel.TVPath4);
            }

            return(tvItemUserAuthorizationModel);
        }