Example #1
0
        // UpdateCatagory
        public bool UpdateCatagory(CatagoryEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx
                             .Catagories
                             .Single(e => e.CatagoryId == model.CatagoryId && e.OwnerId == _userId);
                entity.Name        = model.Name;
                entity.Description = model.Description;

                return(ctx.SaveChanges() == 1);
            }
        }
Example #2
0
        public ActionResult Edit(int id)
        {
            var service = CreateCatagoryService();
            var detail  = service.GetCatagoryById(id);
            var model   =
                new CatagoryEdit
            {
                CatagoryId  = detail.CatagoryId,
                Name        = detail.Name,
                Description = detail.Description
            };

            return(View(model));
        }
Example #3
0
        public bool UpdateCatagory(CatagoryEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Catagories
                    .Single(e => e.CatagoryId == model.CatagoryId && e.OwnerId == _userId);

                entity.Title       = model.Title;
                entity.Content     = model.Content;
                entity.ModifiedUtc = DateTimeOffset.UtcNow;

                return(ctx.SaveChanges() == 1);
            }
        }
Example #4
0
        public ActionResult Edit(int id, CatagoryEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (model.CatagoryId != id)
            {
                ModelState.AddModelError("", "Catagory ID Missmatch");
                return(View(model));
            }

            var service = CreateCatagoryService();

            if (service.UpdateCatagory(model))
            {
                TempData["SaveResult"] = " Catagory was updated.";
                return(RedirectToAction("Index"));
            }

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