public void Initialize() { AutoMapperConfigurator.Configure(); _repositoryMock = new Mock<IRepository<StoredStudy>>(); _storedStudy = new StoredStudy(); { }; // TODO insert data _study = new Study { }; // TODO insert data }
/// <summary> /// Tries to update the state of a study in the database with the given id to the state of the given study object. /// The update returns true if the update is complete, false otherwise /// </summary> /// <param name="id"> /// The id of the study requested for update /// </param> /// <param name="study"> /// The study object with the state which the chosen study should be updated to /// </param> /// <returns> /// A response message indicating the result of the request /// </returns> public HttpResponseMessage UpdateTask(Study study) { try { var result = _studyHandler.Update(study).Result; return CreateResponse(result ? HttpStatusCode.OK : HttpStatusCode.BadRequest); } catch (Exception exception) { return CreateResponse(HttpStatusCode.BadRequest, exception.Message); } }
/// <summary> /// Method for creating a study with a state matching the given study object's state /// </summary> /// <param name="study"> /// The given study to be created in the database /// </param> /// <returns> /// A response message indicating the result of the request /// </returns> public HttpResponseMessage CreateStudy(Study study) { try { var userId = _studyHandler.Create(study).Result; return CreateResponse(HttpStatusCode.OK); } catch (Exception exception) { return CreateResponse(HttpStatusCode.BadRequest, exception.Message); } }