Ejemplo n.º 1
0
        public ListResponse <CategoryContract> GetAllCategory()
        {
            var response = new ListResponse <CategoryContract>();

            try
            {
                using (var context = new CookEntities())
                {
                    response.Items = context.Categories.Select(n => new CategoryContract()
                    {
                        CategoryName         = n.CategoryName,
                        CategoryIntroduction = n.CategoryIntroduction
                    }).ToList();
                }
            }
            catch (Exception)
            {
                response.Success = false;
            }

            response.Success = true;

            return(response);
        }
Ejemplo n.º 2
0
        public ListResponse <UserContract> GetAllUsers()
        {
            var response = new ListResponse <UserContract>();

            try
            {
                using (var context = new CookEntities())
                {
                    response.Items = context.Users.Select(n => new UserContract()
                    {
                        UserName = n.UserName,
                        Email    = n.Email
                    }).ToList();
                }
            }
            catch (Exception)
            {
                response.Success = false;
            }

            response.Success = true;

            return(response);
        }