예제 #1
0
        public async Task <int> AddOrUpdateLanguage(CategoryLanguage language)
        {
            string cmd  = QueriesCreatingHelper.CreateQuerySelect <CategoryLanguage>($"category_id = {language.CategoryId} AND language_id = {language.LanguageId}");
            var    lang = (await DALHelper.ExecuteQuery <CategoryLanguage>(cmd, dbTransaction: DbTransaction, connection: DbConnection)).FirstOrDefault();

            if (lang == null)
            {
                cmd  = QueriesCreatingHelper.CreateQueryInsert(language);
                cmd += ";SELECT LAST_INSERT_ID();";
                return(await DALHelper.Execute(cmd, dbTransaction : DbTransaction, connection : DbConnection));
            }
            else
            {
                language.Id = lang.Id;
                cmd         = QueriesCreatingHelper.CreateQueryUpdate(language);
                var rs = await DALHelper.Execute(cmd, dbTransaction : DbTransaction, connection : DbConnection);

                return(rs == 0 ? -1 : language.Id);
            }
        }
예제 #2
0
        public async Task <T> Get(long id)
        {
            string cmd = QueriesCreatingHelper.CreateQuerySelect <T>($"`id` = {id}");

            return((await DALHelper.ExecuteQuery <T>(cmd)).FirstOrDefault());
        }
예제 #3
0
        public async Task <IEnumerable <T> > Gets(string condition = "")
        {
            string cmd = QueriesCreatingHelper.CreateQuerySelect <T>(condition);

            return(await DALHelper.ExecuteQuery <T>(cmd));
        }
예제 #4
0
        public async Task <IEnumerable <Language> > Gets(string condition = "")
        {
            string cmd = QueriesCreatingHelper.CreateQuerySelect <Language>(condition);

            return(await DALHelper.ExecuteQuery <Language>(cmd, dbTransaction : DbTransaction, connection : DbConnection));
        }