Exemplo n.º 1
0
 public static Category GetCategoryById(int categoryId)
 {
     using (CariHesapDbEntities c = new CariHesapDbEntities())
     {
         return(c.Category.Find(categoryId));
     }
 }
Exemplo n.º 2
0
 public static Customer GetCustomerById(int customerId)
 {
     using (CariHesapDbEntities c = new CariHesapDbEntities())
     {
         return(c.Customer.Find(customerId));
     }
 }
Exemplo n.º 3
0
 public static Product GetProductById(int productId)
 {
     using (CariHesapDbEntities c = new CariHesapDbEntities())
     {
         return(c.Product.Find(productId));
     }
 }
Exemplo n.º 4
0
 public static User GetUserById(int userId)
 {
     using (CariHesapDbEntities c = new CariHesapDbEntities())
     {
         return(c.User.Find(userId));
     }
 }
Exemplo n.º 5
0
 public static List <Product> GetProductByCategoryId(int categoryId)
 {
     using (CariHesapDbEntities c = new CariHesapDbEntities())
     {
         return(c.Product.Where(x => x.CategoryId == categoryId).ToList());
     }
 }
Exemplo n.º 6
0
 public static List <Category> GetCategoryList()
 {
     using (CariHesapDbEntities c = new CariHesapDbEntities())
     {
         return(c.Category.ToList());
     }
 }
Exemplo n.º 7
0
 public static List <Sale> GetSaleList()
 {
     using (CariHesapDbEntities c = new CariHesapDbEntities())
     {
         return(c.Sale.ToList());
     }
 }
Exemplo n.º 8
0
 public static List <Customer> GetCustomerList()
 {
     using (CariHesapDbEntities c = new CariHesapDbEntities())
     {
         return(c.Customer.ToList());
     }
 }
Exemplo n.º 9
0
 public static List <Product> GetProductList()
 {
     using (CariHesapDbEntities c = new CariHesapDbEntities())
     {
         return(c.Product.ToList());
     }
 }
Exemplo n.º 10
0
 public static User GetUserByName(string userName)
 {
     using (CariHesapDbEntities c = new CariHesapDbEntities())
     {
         return(c.User.Where(x => x.UserName == userName).FirstOrDefault());
     }
 }
Exemplo n.º 11
0
 public static (User, bool) UserCUD(User user, EntityState entityState)
 {
     using (CariHesapDbEntities c = new CariHesapDbEntities())
     {
         c.Entry(user).State = entityState;
         if (c.SaveChanges() > 0)
         {
             return(user, true);
         }
         else
         {
             return(user, false);
         }
     }
 }
Exemplo n.º 12
0
 public static (Category, bool) CategoryCUD(Category category, EntityState entityState)
 {
     using (CariHesapDbEntities c = new CariHesapDbEntities())
     {
         c.Entry(category).State = entityState;
         if (c.SaveChanges() > 0)
         {
             return(category, true);
         }
         else
         {
             return(category, false);
         }
     }
 }
Exemplo n.º 13
0
 public static (Product, bool) ProductCUD(Product product, EntityState entityState)
 {
     using (CariHesapDbEntities c = new CariHesapDbEntities())
     {
         c.Entry(product).State = entityState;
         if (c.SaveChanges() > 0)
         {
             return(product, true);
         }
         else
         {
             return(product, false);
         }
     }
 }
Exemplo n.º 14
0
 public static (Sale, bool) SaleAdd(Sale sale)
 {
     using (CariHesapDbEntities c = new CariHesapDbEntities())
     {
         var a = c.Sale.Add(sale);
         if (c.SaveChanges() > 0)
         {
             return(a, true);
         }
         else
         {
             return(a, false);
         }
     }
 }
Exemplo n.º 15
0
 public static List <SaleModel> GetSaleModelByProductName(string productName)
 {
     using (CariHesapDbEntities c = new CariHesapDbEntities())
     {
         List <SaleModel> saleModelsHelper = new List <SaleModel>();
         List <SaleModel> saleModels       = GetSaleModelList();
         foreach (var item in saleModels)
         {
             if (item.Product.Name.ToLower().Contains(productName.ToLower()))
             {
                 saleModelsHelper.Add(item);
             }
         }
         return(saleModelsHelper);
     }
 }
Exemplo n.º 16
0
 public static List <SaleModel> GetSaleModelByCategoryName(string categoryName)
 {
     using (CariHesapDbEntities c = new CariHesapDbEntities())
     {
         List <SaleModel> saleModelsHelper = new List <SaleModel>();
         List <SaleModel> saleModels       = GetSaleModelList();
         foreach (var item in saleModels)
         {
             Category category = GetCategoryById((int)item.Product.CategoryId);
             if (category.Name.ToLower().Contains(categoryName.ToLower()))
             {
                 saleModelsHelper.Add(item);
             }
         }
         return(saleModelsHelper);
     }
 }
Exemplo n.º 17
0
 public static List <SaleModel> GetSaleModelList()
 {
     using (CariHesapDbEntities c = new CariHesapDbEntities())
     {
         List <Sale>      sales      = GetSaleList();
         List <SaleModel> saleModels = new List <SaleModel>();
         foreach (var item in sales)
         {
             SaleModel saleModel = new SaleModel();
             saleModel.SaleId   = item.SaleId;
             saleModel.Count    = item.Count;
             saleModel.Date     = item.Date;
             saleModel.Product  = GetProductById((int)item.ProductId);
             saleModel.Custemer = GetCustomerById((int)item.CustemerId);
             saleModels.Add(saleModel);
         }
         return(saleModels);
     }
 }