Ejemplo n.º 1
0
        public ActionResult Create(Kid kid)
        {
            //check if the fundraiser already refered to this kid
            // the first name , last name , diagnosis and  fundraiser id
            // TODO: check if it is working or not
            //FundRaiser fundRaiser = FundRaiserService.GetById(kid.FundRaiserID);
            //var checkKidUnique = fundRaiser.Kids.Contains(kid) ;


            if (ModelState.IsValid /*&& checkKidUnique*/)
            {
                //calculate the age
                int age = DateTime.Today.Year - kid.KidBirthdate.Year;
                kid.Age = age;

                service.Add(kid);
                service.Commit();
                //service.Dispose();



                return(RedirectToAction("Create", "Wishes", new { id = kid.KidID }));
            }

            ViewBag.FundRaiserID = new SelectList(db.Fundraisers, "FundRaiserID", "Email", kid.FundRaiserID);
            ViewBag.Message      = "you already refered to this kid";
            return(View(kid));
        }
        public ActionResult DeleteKid(int id)
        {
            Kid c = ks.GetById(id);

            ks.Delete(c);
            ks.Commit();
            return(RedirectToAction("Profil"));
        }
Ejemplo n.º 3
0
        // [ValidateAntiForgeryToken]
        public JsonResult Delete(int id)
        {
            //delete the wish
            Wish wish = service.GetById(id);

            service.Delete(wish);
            service.Commit();

            //delete the kid
            Kid kid = KidService.GetById(wish.KidID);

            KidService.Delete(kid);
            KidService.Commit();

            return(Json("wish deleted"));
        }