コード例 #1
0
 public async Task <IEnumerable <Marca> > GetAll()
 {
     using (_context = new PhonesContext())
     {
         return(await _context.Marcas.ToListAsync());
     }
 }
コード例 #2
0
 public async Task <IEnumerable <Phone> > GetAll()
 {
     using (_context = new PhonesContext())
     {
         return(await _context.Phones.Include(p => p.Modelo).ToListAsync());
     }
 }
コード例 #3
0
 public async Task <IEnumerable <RepairOrder> > GetAll()
 {
     using (_context = new PhonesContext())
     {
         return(await _context.RepairOrders.Include(rp => rp.Cliente).Include(rp => rp.Phone.Modelo).ToListAsync());
     }
 }
コード例 #4
0
 public async Task <RepairOrder> FindOneById(int id)
 {
     using (_context = new PhonesContext())
     {
         return(await(from rp in _context.RepairOrders.Include(rp => rp.Cliente).Include(rp => rp.Phone.Modelo.Marca) where rp.Id == id select rp).SingleOrDefaultAsync());
     }
 }
コード例 #5
0
 public async Task Delete(Phone entity)
 {
     using (_context = new PhonesContext())
     {
         _context.Entry(entity).State = EntityState.Deleted;
         await _context.SaveChangesAsync();
     }
 }
コード例 #6
0
 public async Task <IEnumerable <Modelo> > GetAll()
 {
     using (_context = new PhonesContext())
     {
         // Recupero todos los modelos con el objeto marca relacionado //
         return(await _context.Modelos.Include(m => m.Marca).ToListAsync());
     }
 }
コード例 #7
0
 public async Task Delete(Modelo model)
 {
     using (_context = new PhonesContext())
     {
         model = _context.Modelos.Find(model.Id);
         _context.Entry(model).State = EntityState.Deleted;
         await _context.SaveChangesAsync();
     }
 }
コード例 #8
0
 public async Task Update(Modelo model)
 {
     using (_context = new PhonesContext())
     {
         _context.Entry(model).State       = EntityState.Modified;
         _context.Entry(model.Marca).State = EntityState.Unchanged;
         await _context.SaveChangesAsync();
     }
 }
コード例 #9
0
 public async Task Update(Phone entity)
 {
     using (_context = new PhonesContext())
     {
         _context.Entry(entity.Modelo).State = EntityState.Modified;
         _context.Entry(entity).State        = EntityState.Modified;
         await _context.SaveChangesAsync();
     }
 }
コード例 #10
0
 public async Task Update(RepairOrder entity)
 {
     using (_context = new PhonesContext())
     {
         _context.Entry(entity.Phone).State   = EntityState.Modified;
         _context.Entry(entity.Cliente).State = EntityState.Modified;
         _context.Entry(entity).State         = EntityState.Modified;
         await _context.SaveChangesAsync();
     }
 }
コード例 #11
0
 public MainViewModel()
 {
     Db = new PhonesContext();
     Db.Phones.Load();
     Phones     = Db.Phones.Local;
     WinState   = PackIconKind.WindowMaximize;
     ListStyles = new List <string>();
     ListStyles.Add("Dark");
     ListStyles.Add("Light");
     SelectedStyle = ListStyles[0];
     Languages     = new List <string>();
     Languages.Add("Русский");
     Languages.Add("English");
     Languages.Add("Українська");
     SelectedLanguage = Languages[0];
 }
コード例 #12
0
        public PhonesController(PhonesContext context)
        {
            db = context;

            if (!db.Phones.Any())
            {
                db.Phones.Add(new Phones {
                    Name = "Huawei p20 pro", Brend = "Huawei", Price = 1290.00m
                });
                db.Phones.Add(new Phones {
                    Name = "Iphone 7", Brend = "Apple inc.", Price = 990.00m
                });
                db.Phones.Add(new Phones {
                    Name = "Xiaomi Redmi 5", Brend = "Xiaomi", Price = 349.00m
                });
                db.SaveChanges();
            }
        }
コード例 #13
0
 public ReservationRepository(PhonesContext context)
 {
     _context = context;
 }
コード例 #14
0
 public GenericRepository(PhonesContext context)
 {
     _context = context;
 }
コード例 #15
0
 public PhonesController(PhonesContext context)
 {
     _context = context;
 }
コード例 #16
0
 public OrderRepository(PhonesContext context)
 {
     _context = context;
 }
コード例 #17
0
 public PhoneRepository(PhonesContext context)
 {
     _context = context;
 }