public ActionResult ArtifactCreate(ArtifactCreate model) { if (!ModelState.IsValid) { return(View(model)); } var userId = Guid.Parse(User.Identity.GetUserId()); var service = new ArtifactService(userId); service.CreateArtifact(model); return(RedirectToAction("ArtifactIndex")); }
public bool CreateArtifact(ArtifactCreate model) { var entity = new Artifact() { OwnerId = _userId, ArtifactType = model.ArtifactType, ShortLabel = model.ShortLabel, Description = model.Description, Link = model.Link, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Artifacts.Add(entity); return(ctx.SaveChanges() == 1); } }