Ejemplo n.º 1
0
        public bool UpdateCardProperty(CardPropEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx
                             .CardProperties
                             .Single(e => e.Id == model.PropertyId);
                entity.Value = model.Value;

                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            var service  = new CardService();
            var property = service.GetCardPropById(id);
            var model    = new CardPropEdit
            {
                PropertyId = property.Id,
                Value      = property.Value,
                CardId     = property.CardId,
            };

            ViewData["PropertyName"] = property.PropertyName;
            ViewData["CardName"]     = service.GetCardById(property.CardId).Name;

            return(View(model));
        }
Ejemplo n.º 3
0
        public ActionResult Edit(int id, CardPropEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.PropertyId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = new CardService();

            if (service.UpdateCardProperty(model))
            {
                TempData["SaveResult"] = "The Property was updated.";
                return(RedirectToAction("Details", "Card", new { id = model.CardId }));
            }

            ModelState.AddModelError("", "The Property could not be updated.");
            return(View(model));
        }