Esempio n. 1
0
        public ActionResult Create(DragonCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new DragonService(userId);

            service.CreateDragon(model);

            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public bool CreateDragon(DragonCreate model)
        {
            var entity =
                new DragonEntity()
            {
                OwnerId           = _userId,
                DragonName        = model.DragonName,
                DragonColor       = model.DragonColor,
                DragonDescription = model.DragonDescription,
                BirthOfDragon     = DateTimeOffset.Now
            };

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