Exemplo n.º 1
0
 private static Response <IEnumerable <User> > GetResponse(WorkDataResult <IEnumerable <User> > result)
 {
     return(new Response <IEnumerable <User> >
     {
         Data = result.Data,
         IsSuccess = result.IsSucces,
     });
 }
        public WorkDataResult <User> Remove(User item)
        {
            var result = new WorkDataResult <User>();

            try
            {
                _users.Remove(item);
            }
            catch (ArgumentOutOfRangeException ex)
            {
                result.IsSucces = false;
                result.Data     = null;
            }

            return(result);
        }
        public WorkDataResult <User> Update(User targetItem, User newItem)
        {
            var result = new WorkDataResult <User>();

            try
            {
                _users[_users.IndexOf(targetItem)] = newItem;

                result.Data = newItem;
            }
            catch (ArgumentOutOfRangeException ex)
            {
                result.IsSucces = false;
                result.Data     = null;
            }

            return(result);
        }
        public WorkDataResult <User> Get(int index)
        {
            var result = new WorkDataResult <User>();

            try
            {
                var user = _users[index];

                result.IsSucces = true;
                result.Data     = user;
            }
            catch (ArgumentOutOfRangeException ex)
            {
                result.IsSucces = false;
                result.Data     = null;
            }

            return(result);
        }
        public WorkDataResult <User> Add(User user)
        {
            var result = new WorkDataResult <User>();

            try
            {
                _users.Add(user);

                result.IsSucces = true;
                result.Data     = user;
            }
            catch (ArgumentOutOfRangeException ex)
            {
                result.IsSucces = false;
                result.Data     = null;
            }

            return(result);
        }