public void InsertOptimalRoute_Config(ConfigOptimalRoute configData) { EntitiesContext ec = new EntitiesContext(); ec.OptimalRoute_Config.Add(configData); ec.SaveChanges(); }
//for inserting distance from front-end json to database public void InsertDistanceInfo(List <Distance_Table> distance_info) { EntitiesContext ec = new EntitiesContext(); ec.Distances.AddRange(distance_info); ec.SaveChanges(); }
public void InsertCustomer(Customer customer) { EntitiesContext ec = new EntitiesContext(); ec.Customers.Add(customer); ec.SaveChanges(); }
public void DeleteCustomer(string id) { int k = Convert.ToInt32(id); EntitiesContext ec = new EntitiesContext(); var c = (from cust in ec.Customers where cust.Id == k select cust).First(); ec.Customers.Remove(c); ec.SaveChanges(); }
//for inserting distance from front-end json to database public void InsertDistanceInfo(List <Distance_Table> distance_info) { if (distance_info.Count() != 0) { EntitiesContext ec = new EntitiesContext(); ec.Distances.AddRange(distance_info); ec.SaveChanges(); } else { MyCustomErrorDetail customError = new MyCustomErrorDetail("Distance list not found", "Please check whether the list is successfully send!"); throw new WebFaultException <MyCustomErrorDetail>(customError, HttpStatusCode.NotFound); } }
public void InsertCustomer(Customer customer) { if (customer != null) { EntitiesContext ec = new EntitiesContext(); ec.Customers.Add(customer); ec.SaveChanges(); } else { MyCustomErrorDetail customError = new MyCustomErrorDetail("Correct customer details not found", "Please check all the customer fields entered are of correct type!"); throw new WebFaultException <MyCustomErrorDetail>(customError, HttpStatusCode.NotFound); } }
public void InsertOptimalRoute_Config(ConfigOptimalRoute configData) { if (configData != null) { EntitiesContext ec = new EntitiesContext(); ec.OptimalRoute_Config.Add(configData); ec.SaveChanges(); } else { MyCustomErrorDetail customError = new MyCustomErrorDetail("Optimal Route Configuration not found", "Please check wheteher config properties with proper input type is provided!"); throw new WebFaultException <MyCustomErrorDetail>(customError, HttpStatusCode.NotFound); } }
public void UpdateCustomer(Customer customer) { EntitiesContext ec = new EntitiesContext(); var c = (from cust in ec.Customers where cust.Id == customer.Id select cust).First(); c.Name = customer.Name; c.PostCode = customer.PostCode; c.HouseNumber = customer.HouseNumber; c.Street = customer.Street; c.Telephone = customer.Telephone; c.Fax = customer.Fax; c.City = customer.City; ec.SaveChanges(); }
public void UpdateCustomer(Customer customer) { if (customer != null) { EntitiesContext ec = new EntitiesContext(); var c = (from cust in ec.Customers where cust.Id == customer.Id select cust).First(); c.Name = customer.Name; c.PostCode = customer.PostCode; c.HouseNumber = customer.HouseNumber; c.Street = customer.Street; c.Telephone = customer.Telephone; c.Fax = customer.Fax; c.City = customer.City; ec.SaveChanges(); } else { MyCustomErrorDetail customError = new MyCustomErrorDetail("Correct customer details not provided", "Please check all the customer fields entered are of correct type!"); throw new WebFaultException <MyCustomErrorDetail>(customError, HttpStatusCode.NotFound); } }