Example #1
0
        public bool CreatePing(PingCreate model)
        {
            var entity = new Ping()
            {
                OwnerId = _userId,

                PingLocation = model.PingLocation,
                SharkTagId   = model.SharkTagId,
                PingDate     = model.PingDate
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Ping.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Create(PingCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = CreatePingService();

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

            ModelState.AddModelError("", "Ping would not be created.");

            return(View(model));
        }