Пример #1
0
        public void AddMale(Males male)
        {
            using (var context = new RabbitsDBEntities())
            {
                if (IsNameExist(male.Name, context))
                    throw new InvalidOperationException(AlreadyExist);

                context.Males.Add(male);
                context.SaveChanges();
            }
        }
Пример #2
0
        public void UpdateMale(Males male)
        {
            using (var context = new RabbitsDBEntities())
            {
                if (IsNameExist(male.Name, context))
                    throw new InvalidOperationException(AlreadyExist);

                var result = context.Males.FirstOrDefault(x => x.Id == male.Id);
                if (result == null)
                    throw new InvalidOperationException(NotFound);

                result.Name = male.Name;

                context.SaveChanges();
            }
        }
Пример #3
0
        public ActionResult UpdateMale(Males male)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    new MalesManager().UpdateMale(male);
                }

                return RedirectToAction(ShowMalesAction);
            }
            catch (InvalidOperationException exception)
            {
                return RedirectToAction(ErrorAction, new { exception });
            }
        }
Пример #4
0
 public void UpdateMale(Males male)
 {
     new MalesRepository().UpdateMale(male);
 }
Пример #5
0
 public void AddMale(Males male)
 {
     new MalesRepository().AddMale(male);
 }