Exemplo n.º 1
0
        public OperationResult <List <Brand> > List()
        {
            try
            {
                var transactionOptions = new TransactionOptions
                {
                    IsolationLevel = IsolationLevel.ReadCommitted,
                    Timeout        = TimeSpan.FromSeconds(30)
                };

                using var transactionScope = new TransactionScope(TransactionScopeOption.Required,
                                                                  transactionOptions, TransactionScopeAsyncFlowOption.Enabled);
                var result = _dao.List();

                transactionScope.Complete();

                return(new OperationResult <List <Brand> >()
                {
                    Success = true, Result = result
                });
            }
            catch (Exception e)
            {
                return(new OperationResult <List <Brand> >()
                {
                    Success = false, Exception = e
                });
            }
        }
Exemplo n.º 2
0
 public OperationResult <bool> Create(Brand item)
 {
     try
     {
         if (_dao.List().Any(x => x.Name.ToLower().Trim() == item.Name.ToLower().Trim() && !x.IsDeleted))
         {
             return new OperationResult <bool>()
                    {
                        Success = true, Result = false, Message = "Name already exists"
                    }
         }
         ;
         _dao.Create(item);
         return(new OperationResult <bool>()
         {
             Success = true, Result = true
         });
     }
     catch (Exception e)
     {
         return(new OperationResult <bool>()
         {
             Success = false, Exception = e
         });
     }
 }