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; } }
public static void AddNewRecord(Inventory inventory) { using (var repo = new InventoryRepo()) { repo.Add(inventory); } }
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); } }
private static void AddNewRecord(Inventory car) { // Add record to the Inventory table of the AutoLot database. using (var repo = new InventoryRepo()) { repo.Add(car); } }
public override void Execute(object parameter) { if (parameter is Inventory car) { car.Id = 0; var repo = new InventoryRepo(); repo.Add(car); } }
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(); }
public void InsertCar(InventoryRecord car) { var repo = new InventoryRepo(); repo.Add(new Inventory { Color = car.Color, Make = car.Make, PetName = car.PetName }); repo.Dispose(); }
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()); } }
public void InsertCar(InventoryRecord car) { InventoryRepo repository = new InventoryRepo(); repository.Add(new Inventory() { Make = car.Make, Color = car.Color, PetName = car.PetName }); repository.Dispose(); }
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); } }
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)); }
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)); }
public static void AddNewRecord(Inventory car) { using (InventoryRepo repo = new InventoryRepo()) { repo.Add(car); } }