public static bool Delete(int id) { sale_pointEntities db = new sale_pointEntities(); db.forma_pagamento.Where(x => x.pgt_id_forma_pagamento == id).ToList().ForEach(y => db.forma_pagamento.Remove(y)); return(db.SaveChanges() > 0); }
public static bool Delete(int id) { sale_pointEntities db = new sale_pointEntities(); db.produto.Where(x => x.pro_id_produto == id).ToList().ForEach(y => db.produto.Remove(y)); if (BuyingSessionModel.GetBuyingSession().sessionProductsListlist.Any(x => x.productId == id)) { return(false); } return(db.SaveChanges() > 0); }
public static BuyingSessionModel AddProduct(int produtcId) { BuyingSessionModel objBuyingSession = GetBuyingSession(); sale_pointEntities db = new sale_pointEntities(); ProductModel productObj = ProductModel.GetProductModel(produtcId); objBuyingSession.sessionProductsListlist.Add(productObj); objBuyingSession.totalValue += double.Parse(productObj.productPrice); objBuyingSession.totalValue = Math.Round(objBuyingSession.totalValue, 2); return(RecordBuyingSession(objBuyingSession)); }
public static List <PaymentMethodModel> List() { List <PaymentMethodModel> paymentMethodList = new List <PaymentMethodModel>(); sale_pointEntities db = new sale_pointEntities(); foreach (forma_pagamento item in db.forma_pagamento.ToList()) { paymentMethodList.Add(new PaymentMethodModel { paymentMethodId = item.pgt_id_forma_pagamento, paymentMethodDescription = item.pgt_ds_forma_pagamento }); } return(paymentMethodList); }
public static bool Delete(int id) { sale_pointEntities db = new sale_pointEntities(); db.categoria.Where(x => x.cat_id_categoria == id).ToList().ForEach(y => db.categoria.Remove(y)); try { return(db.SaveChanges() > 0); } catch (Exception) { return(false); } }
public static List <CategoryModel> List() { List <CategoryModel> categoryList = new List <CategoryModel>(); sale_pointEntities db = new sale_pointEntities(); foreach (categoria item in db.categoria.ToList()) { categoryList.Add(new CategoryModel { categoryId = item.cat_id_categoria, categoryDescription = item.cat_ds_categoria }); } return(categoryList); }
public static PaymentMethodModel GetPaymentMethodModel(int id) { if (id > 0) { sale_pointEntities db = new sale_pointEntities(); forma_pagamento paymentMethodObj = db.forma_pagamento.FirstOrDefault(x => x.pgt_id_forma_pagamento == id) ?? new forma_pagamento(); return(new PaymentMethodModel { paymentMethodId = paymentMethodObj.pgt_id_forma_pagamento, paymentMethodDescription = paymentMethodObj.pgt_ds_forma_pagamento }); } else { return(new PaymentMethodModel()); } }
public static CategoryModel GetCategoryModel(int id) { if (id > 0) { sale_pointEntities db = new sale_pointEntities(); categoria categoryObj = db.categoria.FirstOrDefault(x => x.cat_id_categoria == id) ?? new categoria(); return(new CategoryModel { categoryId = categoryObj.cat_id_categoria, categoryDescription = categoryObj.cat_ds_categoria }); } else { return(new CategoryModel()); } }
public static List <ProductModel> List() { List <ProductModel> productsList = new List <ProductModel>(); sale_pointEntities db = new sale_pointEntities(); foreach (produto item in db.produto.ToList()) { productsList.Add(new ProductModel { productId = item.pro_id_produto, productDescription = item.pro_ds_produto, productPrice = Math.Round(item.pro_ds_preco, 2).ToString(), categoryId = item.pro_id_categoria, categoryDescription = item.categoria.cat_ds_categoria }); } return(productsList); }
public static bool Save(PaymentMethodModel paymentMethodObj) { sale_pointEntities db = new sale_pointEntities(); forma_pagamento pgt = new forma_pagamento(); pgt.pgt_id_forma_pagamento = paymentMethodObj.paymentMethodId; pgt.pgt_ds_forma_pagamento = paymentMethodObj.paymentMethodDescription; if (pgt.pgt_id_forma_pagamento > 0) { db.forma_pagamento.Attach(pgt); db.Entry(pgt).State = EntityState.Modified; } else { db.forma_pagamento.Add(pgt); } return(db.SaveChanges() > 0); }
public static ProductModel GetProductModel(int id) { if (id > 0) { sale_pointEntities db = new sale_pointEntities(); produto productObj = db.produto.FirstOrDefault(x => x.pro_id_produto == id) ?? new produto(); return(new ProductModel { productId = productObj.pro_id_produto, productDescription = productObj.pro_ds_produto, productPrice = Math.Round(productObj.pro_ds_preco, 2).ToString(), categoryId = productObj.pro_id_categoria, categoryDescription = CategoryModel.GetCategoryModel(productObj.pro_id_categoria).categoryDescription }); } else { return(new ProductModel()); } }
public static bool Save(CategoryModel categoryObj) { sale_pointEntities db = new sale_pointEntities(); categoria cat = new categoria(); cat.cat_id_categoria = categoryObj.categoryId; cat.cat_ds_categoria = categoryObj.categoryDescription; if (cat.cat_id_categoria > 0) { db.categoria.Attach(cat); db.Entry(cat).State = EntityState.Modified; } else { db.categoria.Add(cat); } return(db.SaveChanges() > 0); }
public static bool Save(ProductModel productObj) { sale_pointEntities db = new sale_pointEntities(); produto pro = new produto(); pro.pro_id_produto = productObj.productId; pro.pro_ds_produto = productObj.productDescription; pro.pro_ds_preco = double.Parse(productObj.productPrice.Replace(".", ",")); pro.pro_id_categoria = productObj.categoryId; if (pro.pro_id_produto > 0) { db.produto.Attach(pro); db.Entry(pro).State = EntityState.Modified; } else { db.produto.Add(pro); } return(db.SaveChanges() > 0); }