Exemplo n.º 1
0
        public bool CreateGift(GiftCreate model)
        {
            var entity =
                new Gift()
            {
                GiftName        = model.GiftName,
                GiftDescription = model.GiftDescription,
                RegistryEventId = model.RegistryEventId,
                //RegistryEvent = model.RegistryEvent
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Gifts.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 2
0
        public bool CreateGift(GiftCreate model)
        {
            var entity =
                new Gift()
            {
                OwnerID     = _userID,
                Description = model.Description,
                BoughtGift  = model.BoughtGift,
                Person      = model.Person,
                PersonID    = model.PersonID,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Gifts.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 3
0
        public ActionResult Create(GiftCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = CreateGiftService();

            if (service.CreateGift(model))
            {
                // Use TempData rather than ViewBag. TempData removes information after it's accessed
                TempData["SaveResult"] = "Your Event was created.";
                return(RedirectToAction("Index", new { id = model.RegistryEventId }));
            }

            ModelState.AddModelError("", "Your Event could not be created.");
            return(View(model));
        }
Exemplo n.º 4
0
        public ActionResult Create(GiftCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateGiftService();

            if (service.CreateGift(model))
            {
                TempData["SaveResult"] = "Gift was created.";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "New Gift could not be created.");

            return(View(model));
        }