public IEnumerable <ProductSearchViewModel> GetProducts(string productName, string productCode, int categoryID)
 {
     try
     {
         return(_db.Query <ProductSearchViewModel>("prc_GetProducts", new { ProductName = productName, ProductCode = productCode, CategoryID = categoryID }, commandType: CommandType.StoredProcedure));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "An error occurred", "", "");
         throw;
     }
 }
 public IEnumerable <ProductSearchViewModel> GetProducts(string productName, string productCode, int categoryID)
 {
     try
     {
         return(_repository.GetProducts(productName, productCode, categoryID));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "An error occurred", "", "");
         throw;
     }
 }
 public IEnumerable <PaymentMode> GetAllPaymentModes()
 {
     try
     {
         return(_repository.GetAll());
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "An error occurred", "", "");
         throw;
     }
 }
Example #4
0
        //#region IService<Sale,string> Members

        //public Sale GetEntityID(string id)
        //{
        //    return _saleRepository.GetById(id);
        //}

        //public List<Sale> GetAll()
        //{
        //   return _saleRepository.GetAll();
        //}

        //public void Add(Sale bzEntity)
        //{
        //    _saleRepository.AddObject(bzEntity);
        //}

        //public void Delete(Sale bzEntity)
        //{
        //    _saleRepository.DeleteObject(bzEntity);
        //}

        //public void Save(Sale bzEntity)
        //{
        //    _saleRepository.SaveObject(bzEntity);
        //}

        //#endregion


        public decimal CalculateTax(decimal saleAmount, decimal tax)
        {
            try
            {
                decimal taxamount = ((tax / 100) * saleAmount);
                return(taxamount);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "An error occurred", "", "");
                throw;
            }
        }
Example #5
0
 public T GetSingle(Func <T, bool> predicate)
 {
     try
     {
         return(this._repository.Query(predicate).FirstOrDefault());
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "An error occurred", "", "");
         throw;
     }
 }
Example #6
0
 public void RollBackSaleTransaction(string invoiceNo)
 {
     try
     {
         new SaleDetailService().Remove(new SaleDetail {
             InvoiceNumber = invoiceNo
         });
         Remove(new Sale {
             InvoiceNumber = invoiceNo
         });
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "An error occurred", "", "");
         throw;
     }
 }
        //#region IRepository<Sale> Members

        //public Sale GetById(int id)
        //{
        //    using (StoreManagerDBEntities ctx = conn.GetContext())
        //    {
        //        return ctx.Sales.Where(x => x.InvoiceNumber == id.ToString()).FirstOrDefault();
        //    }
        //}

        //public List<Sale> GetAll()
        //{
        //    using (StoreManagerDBEntities ctx = conn.GetContext())
        //    {
        //        return (from s in ctx.Sales
        //                select s).ToList();
        //    }
        //}

        //public void SaveObject(Sale entity)
        //{
        //    using (StoreManagerDBEntities ctx = conn.GetContext())
        //    {
        //        ctx.Sales.Attach(new Sale { InvoiceNumber = entity.InvoiceNumber });
        //        ctx.Sales.ApplyCurrentValues(entity);
        //        ctx.SaveChanges();
        //    }
        //}

        //public void AddObject(Sale entity)
        //{
        //    using (StoreManagerDBEntities ctx = conn.GetContext())
        //    {
        //        ctx.Sales.AddObject(entity);
        //        ctx.SaveChanges();
        //    }
        //}

        //public void DeleteObject(Sale entity)
        //{
        //    using (StoreManagerDBEntities ctx = conn.GetContext())
        //    {
        //        ctx.Sales.DeleteObject(new Sale { InvoiceNumber = entity.InvoiceNumber });
        //        ctx.SaveChanges();
        //    }
        //}

        //#endregion

        //#region IRepository<Sale> Members

        //public Sale GetById<Tid>(Tid id)
        //{
        //    using (StoreManagerDBEntities ctx = conn.GetContext())
        //    {
        //        return ctx.Sales.Where(x => x.InvoiceNumber == id.ToString()).FirstOrDefault();
        //    }
        //}

        //#endregion

        #region ISale Members

        public void RollBackSaleTransaction(string invoiceNo)
        {
            try
            {
                using (StoreManagerDBEntities ctx = new Connection().GetContext())
                {
                    //ctx.SaleDetails.DeleteObject(new SaleDetail { InvoiceNumber = invoiceNo });
                    //ctx.Sales.DeleteObject(new Sale { InvoiceNumber = invoiceNo });

                    ctx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "An error occurred", "", "");
                throw;
            }
        }
Example #8
0
        //#region IRepository<Product> Members

        //public Product GetById(int id)
        //{
        //    using (StoreManagerDBEntities ctx = conn.GetContext())
        //    {
        //        return ctx.Products.Where(x => x.ProductID == id).FirstOrDefault();
        //    }
        //}

        //public List<Product> GetAll()
        //{
        //    using (StoreManagerDBEntities ctx = conn.GetContext())
        //    {
        //        return ctx.Products.Where(p => p.OnSale == true).ToList();
        //    }
        //}

        //public void SaveObject(Product entity)
        //{
        //    using (StoreManagerDBEntities ctx = conn.GetContext())
        //    {
        //        ctx.Products.Attach(new Product { ProductID = entity.ProductID });
        //        ctx.Products.ApplyCurrentValues(entity);
        //        ctx.SaveChanges();
        //    }
        //}

        //public void AddObject(Product entity)
        //{
        //    using (StoreManagerDBEntities ctx = conn.GetContext())
        //    {
        //        ctx.Products.AddObject(entity);
        //        ctx.SaveChanges();
        //    }
        //}

        //public void DeleteObject(Product entity)
        //{
        //    using (StoreManagerDBEntities ctx = conn.GetContext())
        //    {
        //        ctx.Products.DeleteObject(new Product { ProductID = entity.ProductID });
        //        ctx.SaveChanges();
        //    }
        //}

        ////public Product GetById(int id)
        ////{
        ////    using (StoreManagerDBEntities ctx = conn.GetContext())
        ////    {
        ////        return ctx.Products.Where(x => x.ProductID == id).FirstOrDefault();
        ////    }
        ////}

        //public void Discontinue(int id)
        //{
        //    using (StoreManagerDBEntities ctx = conn.GetContext())
        //    {
        //        Product product = ctx.Products.Where(p => p.ProductID ==id).FirstOrDefault();
        //        product.OnSale = false;

        //        SaveObject(product);
        //    }
        //}

        //#endregion

        public void Discontinue(int id)
        {
            try
            {
                using (StoreManagerDBEntities ctx = new Connection().GetContext())
                {
                    Product product = ctx.Products.Where(p => p.ProductID == id).FirstOrDefault();
                    product.OnSale = false;

                    UpdateObject(product);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "An error occurred", "", "");
                throw;
            }
        }
Example #9
0
        public void CalculateSellingPrice(decimal percent, decimal purchasePrice, out decimal sellingPrice, out decimal profitMargin)
        {
            try
            {
                decimal percentage = percent / 100;

                sellingPrice = Math.Round((percentage * purchasePrice) + purchasePrice, 2);
                profitMargin = Math.Round(sellingPrice - purchasePrice, 2);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "An error occurred", "", "");
                throw;
            }
        }
Example #10
0
 public void LogError(Exception ex, string message, string formName, string controlName)
 {
     try
     {
         _logger.LogError(ex, message, formName, controlName);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #11
0
        public IEnumerable <ProductSearchViewModel> GetProducts(string productName, string productCode, int categoryID)
        {
            try
            {
                var param = new DbParameter[] { new SqlParameter {
                                                    ParameterName = "@ProductName", Value = productName
                                                },
                                                new SqlParameter {
                                                    ParameterName = "@ProductCode", Value = productCode
                                                },
                                                new SqlParameter {
                                                    ParameterName = "@CategoryID", Value = categoryID
                                                } };

                return(conn.GetContext().
                       ExecuteStoreQuery <ProductSearchViewModel>("Exec prc_GetProducts @ProductName,@ProductCode,@CategoryID", param).ToList());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "An error occurred", "", "");
                throw;
            }
        }
Example #12
0
        //#region IRepository<PaymentMode,int> Members

        //public PaymentMode GetById(int id)
        //{
        //    using (StoreManagerDBEntities ctx = conn.GetContext())
        //    {
        //        return ctx.PaymentModes.Where(p => p.PaymentModeID == id).FirstOrDefault();
        //    }
        //}

        //public List<PaymentMode> GetAll()
        //{
        //    using (StoreManagerDBEntities ctx = conn.GetContext())
        //    {
        //        return ctx.PaymentModes.ToList();
        //    }
        //}

        //public void SaveObject(PaymentMode entity)
        //{
        //    using (StoreManagerDBEntities ctx = conn.GetContext())
        //    {
        //        ctx.PaymentModes.Attach(new PaymentMode { PaymentModeID = entity.PaymentModeID });
        //        ctx.PaymentModes.ApplyCurrentValues(entity);
        //        ctx.SaveChanges();
        //    }
        //}

        //public void AddObject(PaymentMode entity)
        //{
        //    using (StoreManagerDBEntities ctx = conn.GetContext())
        //    {
        //        ctx.PaymentModes.AddObject(entity);
        //        ctx.SaveChanges();
        //    }
        //}

        //public void DeleteObject(PaymentMode entity)
        //{
        //    using (StoreManagerDBEntities ctx = conn.GetContext())
        //    {
        //        ctx.Taxes.DeleteObject(new Tax { TaxID = entity.PaymentModeID });
        //        ctx.SaveChanges();
        //    }
        //}

        //public PaymentMode[] GetPaymentModes()
        //{
        //    try
        //    {
        //        using (StoreManagerDBEntities ctx = conn.GetContext())
        //        {
        //            return ctx.PaymentModes.ToArray();
        //            //return null;
        //        }
        //    }
        //    catch (Exception ex)
        //    {

        //        throw;
        //    }

        //}

        //#endregion

        public PaymentMode[] GetPaymentModes()
        {
            try
            {
                using (StoreManagerDBEntities ctx = new Connection().GetContext())
                {
                    return(ctx.PaymentModes.ToArray());
                    //return null;
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "An error occurred", "", "");
                throw;
            }
        }
Example #13
0
        public async Task <IHttpActionResult> Post([FromBody] ErrorLogModel errorlog, int StaffId)
        {
            _SCResult <Models.ErrorLogModel> results = new _SCResult <Models.ErrorLogModel>();

            try
            {
                _repo.LogError(errorlog, StaffId);
                results.DeleteUnsavedChanges = true;
                results.UnsavedId            = errorlog.ErrorLogId;
            }
            catch (Exception)
            {
                results.DeleteUnsavedChanges = true;
                results.UnsavedId            = errorlog.ErrorLogId;
            }

            return(Ok(results));
        }
Example #14
0
        public virtual IList <TEntity> GetAll()
        {
            try
            {
                IList <TEntity> results;

                initializeContext();

                results = this.objectSet.ToList();

                return(results);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "An error occurred", "", "");
                throw;
            }
            finally
            {
                DisposeContext();
            }
        }
Example #15
0
 public long LogError(ErrorLog errorLog)
 {
     return(_errorLogRepository.LogError(errorLog));
 }