public async Task <ActionResult> DeleteConfirmed(int id) { Caes caes = await db.Caes.FindAsync(id); db.Caes.Remove(caes); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "ID,Nome,NomeOficial,Raca,Sexo,DataNascimento,Grau,Size,NumeroCaderneta,DataLicenca,NumeroRegisto")] Caes caes) { if (ModelState.IsValid) { db.Entry(caes).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(caes)); }
public async Task <ActionResult> Update(Caes caes) { if (!ModelState.IsValid) { return(View()); } await _caesRepository.Insert(caes); return(RedirectToAction(nameof(ToList))); }
// GET: Caes/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Caes caes = await db.Caes.FindAsync(id); if (caes == null) { return(HttpNotFound()); } return(View(caes)); }
public async Task <ActionResult> Insert(int dono, Caes caes) { if (!ModelState.IsValid) { List <Donos> list = await _donosRepository.FindAlls(); ViewBag.Donos = list.Select(x => new SelectListItem(x.Nome, x.Id.ToString())); return(View()); } await _caesRepository.Insert(caes); await _caesDonosRepository.Insert(new Models.ManyToMany.CaesDono { CaesId = caes.Id, DonosId = dono }); return(RedirectToAction(nameof(ToList))); }
public CaesDono(Caes caes, Donos donos) { Caes = caes; Donos = donos; }