public void Dispose() { if (this.disposed) { return; } this.db.Dispose(); this.db = null; this.disposed = true; }
public void Dispose() { if (this.disposed) { return; } this.db.Dispose(); this.db = null; this.newOrderNotifier = null; this.orderCostCalculation = null; this.disposed = true; }
private static void UpdateMerchandise(IDbGeneralContext db, Merchandise m) { if (db == null) { throw new ArgumentNullException("db"); } if (m == null) { return; } // save merchandise to DB db.Merchandises.AddOrUpdate(p => p.ID, new Merchandise[] { m }); }
private static void UpdateSubgroup(IDbGeneralContext db, Subgroup s) { if (db == null) { throw new ArgumentNullException("db"); } if (s == null) { return; } // save subgroup to DB db.Subgroups.AddOrUpdate(p => p.ID, new Subgroup[] { s }); }
private static void UpdateGroup(IDbGeneralContext db, Group g) { if (db == null) { throw new ArgumentNullException("db"); } if (g == null) { return; } // save group to DB db.Groups.AddOrUpdate(p => p.ID, new Group[] { g }); }
private static void UpdateDiscount(IDbGeneralContext db, Discount d) { if (db == null) { throw new ArgumentNullException("db"); } if (d == null) { return; } // save discount to DB db.Discounts.AddOrUpdate(p => p.ID, new Discount[] { d }); }
public void Dispose() { if (this.disposed) { return; } this.db.Dispose(); this.orderDiscountMap.Clear(); this.orderDiscountMap = null; this.db = null; this.disposed = true; }
private static void ProcessDiscountItem(IDbGeneralContext db, XmlTextReader xr) { if (db == null) { throw new ArgumentNullException("db"); } if (xr == null) { throw new ArgumentNullException("xr"); } int id; double summ; bool isDeleted; string testValue; testValue = xr.GetAttribute("id"); if (!int.TryParse(testValue, out id)) { throw new ApplicationException( String.Format("Не удалось привести идентификатор к типу int. Исходное строковое значение: {0}. XML({1},{2})", testValue, xr.LineNumber, xr.LinePosition)); } testValue = xr.GetAttribute("startSumm"); if (!double.TryParse(testValue, out summ)) { throw new ApplicationException( String.Format("Не удалось привести сумму для определения скидки к типу double. Исходное строковое значение: {0}. XML({1},{2})", testValue, xr.LineNumber, xr.LinePosition)); } testValue = xr.GetAttribute("deleted"); isDeleted = String.Compare(testValue, "true", true) == 0 ? true : false; // Если группа должна быть удалена, то удалить также подгруппы и товары входящие в ее состав if (isDeleted) { DeleteDiscount(db, id); return; } // Добавление или обновление скидки в БД UpdateDiscount(db, new Discount { ID = id, StartSumm = summ }); }
private static void DeleteSubgroup(IDbGeneralContext db, int id) { if (db == null) { throw new ArgumentNullException("db"); } var s = db.Subgroups.Find(id); if (s == null) { return; } // Note mark as deletede instead hard delete //db.Subgroups.Remove(s); s.IsDeleted = true; }
private static void DeleteDiscount(IDbGeneralContext db, int id) { if (db == null) { throw new ArgumentNullException("db"); } var d = db.Discounts.Find(id); if (d == null) { return; } // Note mark as deletede instead hard delete //db.Discounts.Remove(d); d.IsDeleted = true; }
private static void ProcessSubgroupItem(IDbGeneralContext db, XmlTextReader xr, int groupId, out int id) { if (db == null) { throw new ArgumentNullException("db"); } if (xr == null) { throw new ArgumentNullException("xr"); } string title; bool isDeleted; string testValue; testValue = xr.GetAttribute("id"); if (!int.TryParse(testValue, out id)) { throw new ApplicationException( String.Format("Не удалось привести идентификатор подгруппы к типу int. Исходное строковое значение: {0}. XML({1},{2})", testValue, xr.LineNumber, xr.LinePosition)); } title = xr.GetAttribute("title"); if (String.IsNullOrEmpty(title)) { throw new ApplicationException( String.Format("Имя подгруппы не должно быть пустым. XML({0},{1}).", xr.LineNumber, xr.LinePosition)); } testValue = xr.GetAttribute("deleted"); isDeleted = String.Compare(testValue, "true", true) == 0 ? true : false; // Если подгруппа должна быть удалена, то удалить также товары входящие в ее состав if (isDeleted) { DeleteSubgroup(db, id); return; } // Добавление или обновление подгруппы в БД UpdateSubgroup(db, new Subgroup { ID = id, GroupID = groupId, Title = title }); }
private static void DeleteMerchandise(IDbGeneralContext db, int id, int subgroupId) { if (db == null) { throw new ArgumentNullException("db"); } // delete merchandise from DB var item = db.Merchandises.FirstOrDefault(m => m.ID == id && m.SubgroupID == subgroupId); if (item == null) { return; } // Note mark as deletede instead hard delete //db.Merchandises.Remove(item); //idDelList.Add(id); item.IsDeleted = true; }
public OrderRepository() { this.db = new AltechContext(); }
private static void ProcessMerchandiseItem(IDbGeneralContext db, XmlTextReader xr, int subgroupId) { if (db == null) { throw new ArgumentNullException("db"); } if (xr == null) { throw new ArgumentNullException("xr"); } int id; string title; string measureUnits; int pack, minPack; double costWhs1, costWhs2, costWhs3; string imageFileName; bool isDeleted; string testValue; testValue = xr.GetAttribute("id"); if (!int.TryParse(testValue, out id)) { throw new ApplicationException( String.Format("Не удалось привести идентификатор товара к типу int. Исходное строковое значение: {0}. XML({1},{2})", testValue, xr.LineNumber, xr.LinePosition)); } title = xr.GetAttribute("title"); if (String.IsNullOrEmpty(title)) { throw new ApplicationException( String.Format("Имя товара не должно быть пустым. XML({0},{1}).", xr.LineNumber, xr.LinePosition)); } measureUnits = xr.GetAttribute("mu"); if (String.IsNullOrEmpty(measureUnits)) { measureUnits = "шт"; } testValue = xr.GetAttribute("pack"); if (!int.TryParse(testValue, out pack)) { throw new ApplicationException( String.Format("Не удалось привести значение поля Упаковка к типу int. Исходное строковое значение: {0}. XML({1},{2})", testValue, xr.LineNumber, xr.LinePosition)); } testValue = xr.GetAttribute("pack_min"); if (!int.TryParse(testValue, out minPack)) { throw new ApplicationException( String.Format("Не удалось привести значение поля Мин. упаковка к типу int. Исходное строковое значение: {0}. XML({1},{2})", testValue, xr.LineNumber, xr.LinePosition)); } testValue = xr.GetAttribute("cost_whs1").Replace(',', '.'); if (!double.TryParse(testValue, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out costWhs1)) { throw new ApplicationException( String.Format("Не удалось привести значение поля Цена к типу double. Исходное строковое значение: {0}. XML({1},{2})", testValue, xr.LineNumber, xr.LinePosition)); } testValue = xr.GetAttribute("cost_whs2").Replace(',', '.'); if (!double.TryParse(testValue, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out costWhs2)) { throw new ApplicationException( String.Format("Не удалось привести значение поля Опт к типу double. Исходное строковое значение: {0}. XML({1},{2})", testValue, xr.LineNumber, xr.LinePosition)); } testValue = xr.GetAttribute("cost_whs3").Replace(',', '.'); if (!double.TryParse(testValue, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out costWhs3)) { throw new ApplicationException( String.Format("Не удалось привести значение поля Опт к типу double. Исходное строковое значение: {0}. XML({1},{2})", testValue, xr.LineNumber, xr.LinePosition)); } imageFileName = xr.GetAttribute("img"); testValue = xr.GetAttribute("deleted"); isDeleted = String.Compare(testValue, "true", true) == 0 ? true : false; if (isDeleted) { DeleteMerchandise(db, id, subgroupId); return; } // Добавление или обновление товара в БД UpdateMerchandise( db, new Merchandise { ID = id, SubgroupID = subgroupId, Title = title, UnitMeasure = measureUnits, Pack = pack, PackMin = minPack, CostWhs1 = costWhs1, CostWhs2 = costWhs2, CostWhs3 = costWhs3, ImageName = imageFileName }); }
public CatalogRepository() { this.db = new AltechContext(); }
public OrderCostCalculation() { this.db = new AltechContext(); }