public async Task <OperationResult <bool> > CreateAsync(Category item)
        {
            try
            {
                if (_dao.ListAsync().Result.Any(x => x.Name.ToLower().Trim() == item.Name.ToLower().Trim() && !x.IsDeleted))
                {
                    return new OperationResult <bool>()
                           {
                               Success = true, Result = false, Message = "Name already exists"
                           }
                }
                ;
                await _dao.CreateAsync(item);

                return(new OperationResult <bool>()
                {
                    Success = true, Result = true
                });
            }
            catch (Exception e)
            {
                return(new OperationResult <bool>()
                {
                    Success = false, Exception = e
                });
            }
        }
Exemplo n.º 2
0
        public async Task <OperationResult> CreateAsync(Category item)
        {
            try
            {
                await _dao.CreateAsync(item);

                return(new OperationResult()
                {
                    Success = true
                });
            }
            catch (Exception e)
            {
                return(new OperationResult()
                {
                    Success = false, Exception = e
                });
            }
        }