Exemplo n.º 1
0
        public void AddCage(Cages cage)
        {
            using (var context = new RabbitsDBEntities())
            {
                if (IsNameExist(cage.Name, context))
                    throw new InvalidOperationException(AlreadyExist);

                context.Cages.Add(cage);
                context.SaveChanges();
            }
        }
Exemplo n.º 2
0
 public ActionResult UpdateCage(Cages cage)
 {
     try
     {
         if (ModelState.IsValid)
             new CagesManager().UpdateCage(cage);
     
         return RedirectToAction(ActionShowCages);
     }
     catch (InvalidOperationException exception)
     {
         return RedirectToAction(ActionError, new { exception });
     }
 }
Exemplo n.º 3
0
        public void UpdateCage(Cages cage)
        {
            using (var context = new RabbitsDBEntities())
            {
                if (IsNameExist(cage.Name, context))
                    throw new InvalidOperationException(AlreadyExist);

                var entity = context.Cages.FirstOrDefault(x => x.Id == cage.Id);

                if (entity == null)
                    throw new InvalidOperationException(DoesNotExist);

                entity.Name = cage.Name;

                context.SaveChanges();
            }
        }
Exemplo n.º 4
0
 public void UpdateCage(Cages cage)
 {
     new CagesRepository().UpdateCage(cage);
 }
Exemplo n.º 5
0
 public void AddCage(Cages cage)
 {
     new CagesRepository().AddCage(cage);
 }