Beispiel #1
0
        // CreateCatagory
        public bool CreateCatagory(CatagoryCreate model)
        {
            var entity = new Catagory()
            {
                OwnerId     = _userId,
                Name        = model.Name,
                Description = model.Description,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Catagories.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public bool CreateCatagory(CatagoryCreate model)
        {
            var entity =
                new Catagory()
            {
                OwnerId    = _userId,
                Title      = model.Title,
                Content    = model.Content,
                CreatedUtc = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Catagories.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Beispiel #3
0
        public ActionResult Create(CatagoryCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = CreateCatagoryService();

            if (service.CreateCatagory(model))
            {
                TempData["SaveResult"] = " You added a Catagory.";
                return(RedirectToAction("Index"));
            }
            ;
            ModelState.AddModelError("", "Catagory could not be added.");
            return(View(model));
        }