예제 #1
0
        public async Task <ResponseMODEL> GetAllAsync()
        {
            try
            {
                var resultProcess = await authorDAL.GetAllAsync();

                if (resultProcess.IsApproved)
                {
                    List <Author> result = (List <Author>)resultProcess.ObjectResult;
                    if (result.Count == 0)
                    {
                        return(ResponseMODEL.Instance(true, "Consulta Exitosa", "Lista Vacia", "La tabla \"Autor\" esta vacia", result));
                    }
                    else
                    {
                        var resultList = result.Select(i => new AuthorMODEL
                        {
                            Email      = i.Email,
                            BirthDate  = i.BirthDate,
                            CityOrigin = i.CityOrigin,
                            FullName   = i.FullName,
                            IdAuthor   = i.IdAuthor
                        }
                                                       ).ToList();

                        resultProcess.ObjectResult = null;
                        resultProcess.ObjectResult = resultList;
                    }
                }


                return(resultProcess);
            }
            catch (Exception ex)
            {
                return(ResponseMODEL.Instance(false, "Error Controlado", "Se controlo un error en la aplicacion.", ex.Message, ex));
            }
        }