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")); }
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); } }