public Result <StatusUpdate> CreateStatusUpdate(CreateStatusUpdateOptions options) { if (options == null) { return(Result <StatusUpdate> .CreateFailed(StatusCode.BadRequest, "Null options")); } var project = projectService_.GetProjectById(options.ProjectId).Data; if (project == null) { return(Result <StatusUpdate> .CreateFailed(StatusCode.BadRequest, $"Project with {options.ProjectId} was not found")); } var statusupdate = new StatusUpdate() { ProjectId = options.ProjectId, Title = options.Title, Description = options.Description, }; if (!statusupdate.IsValidTitle(options.Title) || !statusupdate.IsValidDescription(options.Description)) { return(Result <StatusUpdate> .CreateFailed(StatusCode.BadRequest, "Please check the validations")); } project.StatusUpdates.Add(statusupdate); if (context_.SaveChanges() <= 0) { return(Result <StatusUpdate> .CreateFailed( StatusCode.InternalServerError, "Status update could not be created")); } return(Result <StatusUpdate> .CreateSuccessful(statusupdate)); }