public void Delete(DeliveryType deliveryType) { using (var s = m_dbManger.OpenSession()) { using (var t = s.BeginTransaction()) { s.Delete(deliveryType); t.Commit(); DeleteFromCache(deliveryType); } } }
public void Add(DeliveryType deliveryType) { using (var s = m_dbManger.OpenSession()) { using (var t = s.BeginTransaction()) { s.Save(deliveryType); t.Commit(); AddToCache(deliveryType); } } }
public DeliveryTypeEdit(Window owner, DeliveryType deliveryType) { m_deliveryType = deliveryType; this.Owner = owner; InitializeComponent(); cbIsActive.IsChecked = m_deliveryType.IsActive; tbComment.Text = m_deliveryType.Comment; tbPrice.Text = m_deliveryType.Price.ToString(); tbMinOrderAmount.Text = m_deliveryType.MinimumOrderSummaryCondition.ToString(); cbMinOrderActivation.IsChecked = m_deliveryType.IsConditional; Title = tbComment.Text.Length < 1 ? "[Новая]" : String.Format("Доставка: {0}", m_deliveryType.Comment); }
private void btnAdd_Click(object sender, RoutedEventArgs e) { var c = new DeliveryType { Comment = "", IsActive = false, IsConditional = false, MinimumOrderSummaryCondition = 0, Price = 0, Id = Int32.MinValue }; var cew = new DeliveryTypeEdit(this, c); cew.ShowDialog(); if (cew.DialogResult.HasValue && cew.DialogResult.Value) { ReloadList(); } }
public DeliveryType GetDeliveryInfo() { if (m_deliveryType == null) { var mgr = Core.Repositories.DbManger.GetInstance(); var repo = mgr.GetDeliveryRepository(); m_deliveryType = repo.GetById(this.DeliveryTypeId); } return m_deliveryType; }
private void lbDeliveries_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count > 0) { var obj = e.AddedItems[0] as DeliveryType; if (obj != null) m_selectedMember = obj; } }
public void Update(DeliveryType deliveryType) { using (var s = m_dbManger.OpenSession()) { using (var t = s.BeginTransaction()) { s.Update(deliveryType); t.Commit(); UpdateInCache(deliveryType); } } }
private void UpdateInCache(DeliveryType p) { if (s_idToDeliveryCache.ContainsKey(p.Id)) s_idToDeliveryCache[p.Id] = p; }
private void DeleteFromCache(DeliveryType p) { if (s_idToDeliveryCache.ContainsKey(p.Id)) s_idToDeliveryCache.Remove(p.Id); }
private void AddToCache(DeliveryType p) { if (!s_idToDeliveryCache.ContainsKey(p.Id)) s_idToDeliveryCache.Add(p.Id, p); }