public BL.Domain.Ideation.Ideation UpdateIdeation(BL.Domain.Ideation.Ideation updatedIdeation) { var entryToUpdate = ReadIdeation(updatedIdeation.IdeationId); if (entryToUpdate == null) { throw new ArgumentException("Ideation to update not found."); } _ctx.Entry(entryToUpdate).CurrentValues.SetValues(updatedIdeation); _ctx.SaveChanges(); return(ReadIdeation(updatedIdeation.IdeationId)); }
public BL.Domain.Ideation.Ideation CreateIdeation(BL.Domain.Ideation.Ideation ideation) { if (ReadIdeation(ideation.IdeationId) != null) { throw new ArgumentException("Ideation already in database."); } try { _ctx.Ideations.Add(ideation); _ctx.SaveChanges(); return(ideation); } catch (DbUpdateException exception) { var msg = exception.InnerException == null ? "Invalid object." : exception.InnerException.Message; throw new ArgumentException(msg); } }