private void detach_CustomerModules(CustomerModule entity) { this.SendPropertyChanging(); entity.Customer = null; }
partial void DeleteCustomerModule(CustomerModule instance);
partial void UpdateCustomerModule(CustomerModule instance);
partial void InsertCustomerModule(CustomerModule instance);
public void SaveModulesByCustomer(Int32 id, Int32[] modulesIds) { try { using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) { CustomerModule customerModule = new CustomerModule(); customerModule.CustomerId = id; foreach (Int32 priceId in modulesIds) { customerModule.ModulePriceId = priceId; db.CustomerModules.InsertOnSubmit(customerModule); } db.SubmitChanges(); } } catch (Exception ex) { throw ex; } }
public void UpdateModules(Int32 id, Int32 moduleId) { CustomerModule query; try { using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) { // Negative - stops service by ending it as of today if (moduleId < 0) { query = db.CustomerModules.Where(m => m.CustomerId == id && m.ModulePriceId == Math.Abs(moduleId) && m.EndDate == null).FirstOrDefault(); if (query != default(CustomerModule)) { query.EndDate = DateTime.Now.Date; } } // Positive - inserts else if (moduleId > 0) { query = new CustomerModule(); query.CustomerId = id; query.ModulePriceId = moduleId; db.CustomerModules.InsertOnSubmit(query); } else if (moduleId == 0) { } db.SubmitChanges(); } } catch (Exception ex) { throw ex; } return; }