public IHttpActionResult Post(CreateArtifact artifact) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateArtifactService(); if (!service.ArtifactCreate(artifact)) { return(InternalServerError()); } return(Ok()); }
public bool ArtifactCreate(CreateArtifact model) { var entity = new Artifact() { OwnerID = _userID, Name = model.Name, Age = model.Age, Power = model.Power, Description = model.Description, PlaceID = model.PlaceID }; using (var ctx = new ApplicationDbContext()) { ctx.Artifacts.Add(entity); return(ctx.SaveChanges() == 1); } }