Esempio n. 1
0
 public async Task <IEnumerable <IComment> > CommentsAsync()
 {
     try
     {
         return(await db.Comments.ToArrayAsync());
     }
     catch (Exception ex)
     {
         logger.LogError(ex);
         throw ex;
     }
 }
        public async Task <Response <IEnumerable <IComment> > > Comments()
        {
            Response <IEnumerable <IComment> > response = new Response <IEnumerable <IComment> >();

            try
            {
                var model = await commentsRepo.CommentsAsync();

                response.Success = true;
                response.Model   = model;
            }
            catch (Exception ex)
            {
                response.Success  = false;
                response.ErrorMsg = "Nastala neočakávaná chyba. Pre bližšie info pozrite prosím logy";
                logger.LogError(ex);
                response.Model = Enumerable.Empty <IComment>();
            }
            return(response);
        }