Пример #1
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Caes caes = await db.Caes.FindAsync(id);

            db.Caes.Remove(caes);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Пример #2
0
        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));
        }
Пример #3
0
        public async Task <ActionResult> Update(Caes caes)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            await _caesRepository.Insert(caes);

            return(RedirectToAction(nameof(ToList)));
        }
Пример #4
0
        // 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));
        }
Пример #5
0
        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)));
        }
Пример #6
0
 public CaesDono(Caes caes, Donos donos)
 {
     Caes  = caes;
     Donos = donos;
 }