Beispiel #1
0
        public async Task <IActionResult> Create([Bind("Id,Name,Company,Price")] Phone phone)
        {
            if (ModelState.IsValid)
            {
                _context.Add(phone);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(phone));
        }
Beispiel #2
0
        public async Task <ActionResult <Phones> > Post([FromBody] Phones phone)
        {
            if (phone == null)
            {
                return(BadRequest());
            }

            db.Phones.Add(phone);
            await db.SaveChangesAsync();

            return(Ok(phone));
        }
 public async Task Delete(Phone entity)
 {
     using (_context = new PhonesContext())
     {
         _context.Entry(entity).State = EntityState.Deleted;
         await _context.SaveChangesAsync();
     }
 }
 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();
     }
 }
Beispiel #5
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();
     }
 }
Beispiel #6
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();
     }
 }
 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();
     }
 }