コード例 #1
0
        /// <inheritdoc/>
        public bool Create(CustomerDto customerDto)
        {
            try
            {
                using (var context = new Connection_Crea_Test_DA())
                {
                    Customer customer = new Customer()
                    {
                        CreatedDate = DateTime.UtcNow,
                        Document    = customerDto.Document,
                        Email       = customerDto.Email,
                        FirtsName   = customerDto.FirtsName,
                        LastName    = customerDto.LastName,
                        Phone       = customerDto.Phone
                    };
                    context.Customer.Add(customer);

                    return(context.SaveChanges() == 1);
                }
            }
            catch (CustomerWorkerException ex)
            {
                throw ex;
            }
        }
コード例 #2
0
ファイル: SaleWorker.cs プロジェクト: dalape/Crea_DiegoA.Core
 private Sale GetSale(int id)
 {
     try
     {
         using (var context = new Connection_Crea_Test_DA())
         {
             return(context.Sale.FirstOrDefault(row => row.ID == id));
         }
     }
     catch (SaleWorkerException ex)
     {
         throw ex;
     }
 }
コード例 #3
0
ファイル: SaleWorker.cs プロジェクト: dalape/Crea_DiegoA.Core
 /// <inheritdoc/>
 public Sale Search(DateTime date)
 {
     try
     {
         using (var context = new Connection_Crea_Test_DA())
         {
             return(context.Sale.FirstOrDefault(row => row.SaleDate == date));
         }
     }
     catch (SaleWorkerException ex)
     {
         throw ex;
     }
 }
コード例 #4
0
 private Customer GetCustomer(string document)
 {
     try
     {
         using (var context = new Connection_Crea_Test_DA())
         {
             return(context.Customer.FirstOrDefault(row => row.Document == document));
         }
     }
     catch (CustomerWorkerException ex)
     {
         throw ex;
     }
 }
コード例 #5
0
 private Product GetProduct(int id)
 {
     try
     {
         using (var context = new Connection_Crea_Test_DA())
         {
             return(context.Product.FirstOrDefault(row => row.ID == id));
         }
     }
     catch (ProductWorkerException ex)
     {
         throw ex;
     }
 }
コード例 #6
0
 /// <inheritdoc/>
 public CustomerDto SearchByName(string name)
 {
     try
     {
         using (var context = new Connection_Crea_Test_DA())
         {
             var customer = context.Customer.FirstOrDefault(row => row.FirtsName.Contains(name) || row.LastName.Contains(name));
             return(ConvertToDto(customer));
         }
     }
     catch (CustomerWorkerException ex)
     {
         throw ex;
     }
 }
コード例 #7
0
 /// <inheritdoc/>
 public CustomerDto Search(int id)
 {
     try
     {
         using (var context = new Connection_Crea_Test_DA())
         {
             var customer = context.Customer.FirstOrDefault(row => row.ID == id);
             return(ConvertToDto(customer));
         }
     }
     catch (CustomerWorkerException ex)
     {
         throw ex;
     }
 }
コード例 #8
0
ファイル: SaleWorker.cs プロジェクト: dalape/Crea_DiegoA.Core
        /// <inheritdoc/>
        public SaleDto Search(Guid salesId)
        {
            try
            {
                using (var context = new Connection_Crea_Test_DA())
                {
                    var sale = context.Sale.FirstOrDefault(row => row.SaleGuid == salesId);

                    return(ConvertToDto(sale));
                }
            }
            catch (SaleWorkerException ex)
            {
                throw ex;
            }
        }
コード例 #9
0
        /// <inheritdoc/>
        public bool ChangeState(string document, bool enable)
        {
            try
            {
                using (var context = new Connection_Crea_Test_DA())
                {
                    var customer = context.Customer.FirstOrDefault(row => row.Document == document);
                    customer.Enable = enable;

                    return(context.SaveChanges() == 1);
                }
            }
            catch (CustomerWorkerException ex)
            {
                throw ex;
            }
        }
コード例 #10
0
        public bool ChangeState(int id, bool enable)
        {
            try
            {
                using (var context = new Connection_Crea_Test_DA())
                {
                    var Product = context.Product.FirstOrDefault(row => row.ID == id);
                    Product.Enable = enable;

                    return(context.SaveChanges() == 1);
                }
            }
            catch (ProductWorkerException ex)
            {
                throw ex;
            }
        }
コード例 #11
0
ファイル: SaleWorker.cs プロジェクト: dalape/Crea_DiegoA.Core
        /// <inheritdoc/>
        public bool Update(SaleDto saleDto)
        {
            try
            {
                using (var context = new Connection_Crea_Test_DA())
                {
                    var Sale = context.Sale.FirstOrDefault(row => row.ID == saleDto.ID);
                    Sale.Quantity = saleDto.Quantity;

                    return(context.SaveChanges() == 1);
                }
            }
            catch (SaleWorkerException ex)
            {
                throw ex;
            }
        }
コード例 #12
0
ファイル: SaleWorker.cs プロジェクト: dalape/Crea_DiegoA.Core
        public bool ChangeState(int id, States state)
        {
            try
            {
                using (var context = new Connection_Crea_Test_DA())
                {
                    var Sale = context.Sale.FirstOrDefault(row => row.ID == id);
                    Sale.State = state.ToString();

                    return(context.SaveChanges() == 1);
                }
            }
            catch (SaleWorkerException ex)
            {
                throw ex;
            }
        }
コード例 #13
0
        /// <inheritdoc/>
        public bool Update(ProductDto productDto)
        {
            try
            {
                using (var context = new Connection_Crea_Test_DA())
                {
                    var Product = context.Product.FirstOrDefault(row => row.ID == productDto.ID);
                    Product.Description = productDto.Description;
                    Product.Name        = productDto.Name;
                    Product.UnitPrice   = productDto.UnitPrice;
                    Product.UpdatedDate = DateTime.UtcNow;

                    return(context.SaveChanges() == 1);
                }
            }
            catch (ProductWorkerException ex)
            {
                throw ex;
            }
        }
コード例 #14
0
        /// <inheritdoc/>
        public bool Update(CustomerDto customerDto)
        {
            try
            {
                using (var context = new Connection_Crea_Test_DA())
                {
                    var customer = context.Customer.FirstOrDefault(row => row.Document == customerDto.Document);
                    customer.Email       = customerDto.Email;
                    customer.FirtsName   = customerDto.FirtsName;
                    customer.LastName    = customerDto.LastName;
                    customer.Phone       = customerDto.Phone;
                    customer.UpdatedDate = DateTime.UtcNow;

                    return(context.SaveChanges() == 1);
                }
            }
            catch (CustomerWorkerException ex)
            {
                throw ex;
            }
        }
コード例 #15
0
        /// <inheritdoc/>
        public bool Create(ProductDto productDto)
        {
            try
            {
                using (var context = new Connection_Crea_Test_DA())
                {
                    Product product = new Product()
                    {
                        CreatedDate = DateTime.UtcNow,
                        Description = productDto.Description,
                        Name        = productDto.Name,
                        UnitPrice   = productDto.UnitPrice
                    };
                    context.Product.Add(product);

                    return(context.SaveChanges() == 1);
                }
            }
            catch (ProductWorkerException ex)
            {
                throw ex;
            }
        }
コード例 #16
0
ファイル: SaleWorker.cs プロジェクト: dalape/Crea_DiegoA.Core
        public bool Create(SaleDto saleDto)
        {
            try
            {
                using (var context = new Connection_Crea_Test_DA())
                {
                    Sale sale = new Sale()
                    {
                        SaleDate   = DateTime.UtcNow,
                        SaleGuid   = saleDto.SalesGuid,
                        CustomerID = saleDto.CustomerID,
                        ProductID  = saleDto.ProductID,
                        Quantity   = saleDto.Quantity
                    };
                    context.Sale.Add(sale);

                    return(context.SaveChanges() == 1);
                }
            }
            catch (SaleWorkerException ex)
            {
                throw ex;
            }
        }
コード例 #17
0
        /// <inheritdoc/>
        public ProductDto Search(string name)
        {
            try
            {
                using (var context = new Connection_Crea_Test_DA())
                {
                    var        product    = context.Product.FirstOrDefault(row => row.Name.Contains(name));
                    ProductDto productDto = new ProductDto()
                    {
                        Description = product.Description,
                        Enable      = Convert.ToBoolean(product.Enable),
                        ID          = product.ID,
                        Name        = product.Name,
                        UnitPrice   = product.UnitPrice
                    };

                    return(productDto);
                }
            }
            catch (ProductWorkerException ex)
            {
                throw ex;
            }
        }