Exemplo n.º 1
0
        public async Task <FaqHomepageViewModel> GetFaqByIdAsync(int faqId)
        {
            FaqHomepageViewModel result = null;
            string cmd = $@"SELECT * FROM `faq` f
                            LEFT JOIN `faq_language` fl ON f.id = fl.faq_id
                            WHERE f.is_deleted = 0 and f.id = {faqId}";

            if (DbConnection != null)
            {
                var rd = await DbConnection.QueryMultipleAsync(cmd, transaction : DbTransaction);

                rd.Read <Faq, FaqLanguage, FaqHomepageViewModel>(
                    (fRs, flRs) =>
                {
                    if (result == null)
                    {
                        result = CommonHelper.Mapper <Faq, FaqHomepageViewModel>(fRs);
                    }


                    if (flRs != null)
                    {
                        result.FaqLanguages.Add(flRs);
                    }

                    return(result);
                }
                    );

                return(result);
            }
            else
            {
                using (var conn = DALHelper.GetConnection())
                {
                    var rd = await conn.QueryMultipleAsync(cmd);

                    rd.Read <Faq, FaqLanguage, FaqHomepageViewModel>(
                        (fRs, flRs) =>
                    {
                        if (result == null)
                        {
                            result = CommonHelper.Mapper <Faq, FaqHomepageViewModel>(fRs);
                        }

                        if (flRs != null)
                        {
                            result.FaqLanguages.Add(flRs);
                        }

                        return(result);
                    }
                        );

                    return(result);
                }
            }
        }
Exemplo n.º 2
0
 public AddCommand(FaqHomepageViewModel faq)
 {
     this.Faq = faq;
 }
Exemplo n.º 3
0
 public UpdateCommand(FaqHomepageViewModel faq)
 {
     this.Faq = faq;
 }