public long CreateNewCustomer(Customer customer) { using (var context = new InvoiceGenEntities()) { context.Customers.Add(customer); context.SaveChanges();//this generates the Id for customer return(customer.ID); } }
public long SaveCustomerProductMapping(CustomerProductMapping customerProductMapping) { using (var context = new InvoiceGenEntities()) { context.CustomerProductMappings.Add(customerProductMapping); context.SaveChanges();//this generates the Id for customer return(customerProductMapping.ID); } }
public long CreateNewBill(BillMaster billMaster) { using (var context = new InvoiceGenEntities()) { context.BillMasters.Add(billMaster); context.SaveChanges();//this generates the Id for customer return(billMaster.ID); } }
public long CreateNewProduct(ProductsMaster products) { using (var context = new InvoiceGenEntities()) { context.ProductsMasters.Add(products); context.SaveChanges();//this generates the Id for customer return(products.ID); } }
public bool CreateNewProductBillMapping(BillProductMapping productBillMapp) { using (var context = new InvoiceGenEntities()) { context.BillProductMappings.Add(productBillMapp); context.SaveChanges();//this generates the Id for customer } if (productBillMapp.ID > 0) { return(true); } else { return(false); } }
/// <summary> /// Saves List of Products to Database /// </summary> /// <param name="listProduct"></param> public List <ProductsMaster> SaveProductsData(List <ProductsMaster> listProduct) { using (var context = new InvoiceGenEntities()) { try { foreach (var product in listProduct) { ProductsMaster prod = new ProductsMaster(); if (product.HSNCode != null) { prod = context.ProductsMasters.SqlQuery("Select * from ProductsMaster where HSNCode=@HSNCode", new SqlParameter("@HSNCode", product.HSNCode)).FirstOrDefault(); } else if (product.SACCode != null) { prod = context.ProductsMasters.SqlQuery("Select * from ProductsMaster where SACCode=@SACCode", new SqlParameter("@SACCode", product.SACCode)).FirstOrDefault(); } if (prod == null) { context.ProductsMasters.Add(product); context.SaveChanges(); } } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { foreach (var ve in eve.ValidationErrors) { throw new Exception(string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage)); } } } catch (Exception ex) { throw ex; } return(listProduct); } }