public bool Add(Party party)
 {
     if (string.IsNullOrEmpty(party.Name))
     {
         throw new Exception("Party name is not provided!");
     }
     if (string.IsNullOrEmpty(party.ContactNo))
     {
         throw  new Exception("party contact no is not provided!");
     }
     return(repository.Add(party));
 }
Esempio n. 2
0
        public ActionResult Create(Party party)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    party.HostedBy = User.Identity.Name;
                    Reservation res = new Reservation();
                    res.Attender = User.Identity.Name;
                    party.Reservations.Add(res);


                    partyRepository.Add(party);
                    partyRepository.Save();
                    return(RedirectToAction("Details", new { id = party.PartyID }));
                }
                catch
                {
                    ModelState.AddRuleViolations(party.GetRuleViolations());
                }
            }
            return(View(party));
        }