public async Task <ActionResult <object> > SelectAsync()
        {
            try
            {
                var items = await _userServiceAsync.GetAll();

                if (items.ToList().Count > 0)
                {
                    var toSerialize = new MessageHelpers <UserViewModel>()
                    {
                        Status = 200,
                        Data   = new List <UserViewModel>(items)
                    };
                    return(JsonConvert.SerializeObject(toSerialize));
                }
                else
                {
                    var toSerialize = new MessageHelpers <UserViewModel>()
                    {
                        Status = 404,
                        Data   = null
                    };
                    return(JsonConvert.SerializeObject(toSerialize));
                }
            }
            catch
            {
                var toSerialize = new MessageHelpers <UserViewModel>()
                {
                    Status = 502,
                    Data   = null
                };
                return(JsonConvert.SerializeObject(toSerialize));
            }
        }
Beispiel #2
0
        public async Task <IEnumerable <UserViewModel> > GetAll()
        {
            var items = await _userServiceAsync.GetAll();

            return(items);
        }