コード例 #1
0
        public void AddTruckSlotInDB(TruckSlot slot)
        {
            try
            {
                Center  to   = db_context.Centers.Where(c => c.CenterName.Equals(slot.ToCenter.CenterName)).FirstOrDefault();
                Center  from = db_context.Centers.Where(c => c.CenterName.Equals(slot.FromCenter.CenterName)).FirstOrDefault();
                Product prod = db_context.Products.Where(p => p.Name.Equals(slot.product.Name)).FirstOrDefault();
                Trip    trip = db_context.Trips.Where(t => t.Id == slot.Trip.Id).Include(t => t.To).Include(tt => tt.From).Include(ttt => ttt.truck).FirstOrDefault();


                slot.product    = prod;
                slot.FromCenter = from;
                slot.ToCenter   = to;
                slot.Trip       = trip;

                db_context.TruckSlots.Add(slot);
                db_context.SaveChanges();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка на уровне взаимодействия с базой данных: " + ex.Message);
            }
        }
コード例 #2
0
 public void AddTruckSlotInDB(TruckSlot slot)
 {
     repository.AddTruckSlotInDB(slot);
 }