public ActionResult Create(SharkTagCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = CreateSharkTagService();

            if (service.CreateSharkTag(model))
            {
                TempData["SaveResult"] = "Your Shark Tagging Event was Created.";
                return(RedirectToAction("Index"));
            }
            ;
            ModelState.AddModelError("", "Shark Tagging Event could not be created.");

            return(View(model));
        }
예제 #2
0
        public bool CreateSharkTag(SharkTagCreate model)
        {
            var entity = new SharkTag()
            {
                OwnerId = _userId,

                StartDate  = model.StartDate,
                SharkId    = model.SharkId,
                TagId      = model.TagId,
                LocationId = model.LocationId
            };

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