예제 #1
0
        private void Cars_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            var action = e.Action;

            switch (action)
            {
            case NotifyCollectionChangedAction.Add:
                foreach (Inventory item in e.NewItems)
                {
                    inventory.Add(item);
                }
                break;

            case NotifyCollectionChangedAction.Remove:
                foreach (Inventory item in e.OldItems)
                {
                    inventory.Delete(item);
                }
                break;

            case NotifyCollectionChangedAction.Replace:
                break;

            case NotifyCollectionChangedAction.Move:
                break;

            case NotifyCollectionChangedAction.Reset:
                break;

            default:
                break;
            }
        }
예제 #2
0
 public static void AddNewRecord(Inventory inventory)
 {
     using (var repo = new InventoryRepo())
     {
         repo.Add(inventory);
     }
 }
예제 #3
0
 private static void AddNewRecord(inventory car)
 {
     using (var repo = new InventoryRepo(new AutoLotContext()))
     {
         repo.Add(car);
     }
 }
 private static void AddNewRecord(Inventory car)
 {
     using (var repo = new InventoryRepo())
     {
         repo.Add(car);
     }
 }
예제 #5
0
 private static void AddNewRecord(Inventory car)
 {
     // Add record to the Inventory table of the AutoLot database.
     using (var repo = new InventoryRepo())
     {
         repo.Add(car);
     }
 }
예제 #6
0
 public override void Execute(object parameter)
 {
     if (parameter is Inventory car)
     {
         car.Id = 0;
         var repo = new InventoryRepo();
         repo.Add(car);
     }
 }
예제 #7
0
    public void InsertCar(string make, string color, string petname)
    {
        var repo = new InventoryRepo();

        repo.Add(new Inventory {
            Color = color, Make = make, PetName = petname
        });
        repo.Dispose();
    }
예제 #8
0
    public void InsertCar(InventoryRecord car)
    {
        var repo = new InventoryRepo();

        repo.Add(new Inventory {
            Color = car.Color, Make = car.Make, PetName = car.PetName
        });
        repo.Dispose();
    }
예제 #9
0
 private static void AddNewRecord(Inventory car)
 {
     //Add Record to the inventory table of the Autolot
     //database
     using (var repo = new InventoryRepo())
     {
         repo.Add(car);
     }
 }
 private void AddCar(Inventory car)
 {
     if (car != null)
     {
         car.Id = 0;
         var repo = new InventoryRepo();
         repo.Add(car);
         Cars = new ObservableCollection <Inventory>(repo.GetAll());
     }
 }
예제 #11
0
    public void InsertCar(InventoryRecord car)
    {
        InventoryRepo repository = new InventoryRepo();

        repository.Add(new Inventory()
        {
            Make = car.Make, Color = car.Color, PetName = car.PetName
        });
        repository.Dispose();
    }
예제 #12
0
    public void InsertCar(string make, string color, string petName)
    {
        InventoryRepo repository = new InventoryRepo();

        repository.Add(new Inventory()
        {
            Make = make, Color = color, PetName = petName
        });
        repository.Dispose();
    }
 //c Added a helper AddNewRecord(Inventory car) to insert new records, using disconnected layer(InventoryReop -> (IRepo) -> BaseRepo -> my context DbSet<Inventory> in memory) -> connected layer(DbContext -> Database)
 // Add record to the Inventory table of the AutoLot database.
 private static void AddNewRecord(Inventory car)
 {
     //First, add car object passed in by user by invoking Add() in BaseRepo,
     //and BaseRepo inserts car object into DbSet<Inventory> property storing values in memory,
     //and finally, within this scope of method, it calls SaveChanges() of DbContext which will do the database job.
     using (var repo = new InventoryRepo())
     {
         repo.Add(car);
     }
 }
예제 #14
0
 public ActionResult Create([Bind(Include = "Make,Color,PetName")] Inventory inventory)
 {
     if (!ModelState.IsValid)
     {
         return(View(inventory));
     }
     try {
         repo.Add(inventory);
     } catch (Exception ex) {
         ModelState.AddModelError(string.Empty, $@"Unable to create record: {ex.Message}");
         return(View(inventory));
     }
     return(RedirectToAction("Index"));
 }
 public IHttpActionResult PostInventory(Inventory inventory)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     try
     {
         _repo.Add(inventory);
     }
     catch (Exception ex)
     {
         // В производственном приложении здесь должны быть дополнительные действия
         throw;
     }
     return(CreatedAtRoute("DisplayRoute", new { id = inventory.Id }, inventory));
 }
예제 #16
0
 public IHttpActionResult PostInventory(Inventory inventory)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     try
     {
         _repo.Add(inventory);
     }
     catch (Exception ex)
     {
         //Production app should do more here
         throw;
     }
     return(CreatedAtRoute("DisplayRoute", new { id = inventory.Id }, inventory));
 }
예제 #17
0
파일: Program.cs 프로젝트: ch3rag/C-Sharp
 public static void AddNewRecord(Inventory car)
 {
     using (InventoryRepo repo = new InventoryRepo()) {
         repo.Add(car);
     }
 }