Example #1
0
        public ActionResult Create(SocialCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateSocialService();

            if (service.CreateSocial(model))
            {
                TempData["SaveResult"] = "Created successfully";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "Entry could not be created.");
            return(View(model));
        }
Example #2
0
        public bool CreateSocial(SocialCreate model)
        {
            var entity =
                new Social()
            {
                OwnerId      = _userId,
                CategoryType = model.CategoryType,
                Title        = model.Title,
                ResourceType = model.ResourceType,
                Description  = model.Description,
                City         = model.City,
                State        = model.State,
                InPerson     = model.InPerson,
                Url          = model.Url,
                CreatedUtc   = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Socials.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }