Esempio n. 1
0
        public bool CreateRepAtBlitz(RepAtBlitzCreate model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                int repId = ctx.Reps.FirstOrDefault(e => e.RepName == model.RepName).RepId;

                int blitzId = ctx.Blitzes.FirstOrDefault(e => e.Name == model.BlitzName).BlitzId;
                var entity  =
                    new RepsAtBlitz()
                {
                    RepsId = model.RepsId,
                    //    BlitzId = model.BlitzId,
                    //HomeArea = model.HomeArea,
                    RepName = model.RepName,
                    //Position = model.Position,
                    //   BlitzName = model.BlitzName,
                    RepId   = repId,
                    BlitzId = blitzId
                };


                ctx.RepsAtBlitzes.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Esempio n. 2
0
        public ActionResult Create(RepAtBlitzCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateRepAtBlitzService();

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

            ModelState.AddModelError("", "RepsAtBlitz could not be created.");

            return(View(model));
        }