public void Create_WithValiData_ShouldSaveDataToDatabase() { // arrange // act var newItem = sut.Create(sample); // assert Assert.IsNotNull(newItem); Assert.IsTrue(newItem.SampleId != Guid.Empty); // cleanup sut.Delete(newItem.SampleId); }
/// <summary> /// Saves a new sample into DB /// </summary> /// <param name="sample">Sample to insert</param> /// <returns></returns> public SampleModel Create(SampleModel sample) { if (sample == null) { throw new ArgumentNullException(); } if (SampleNameIsUsed(sample.Id, sample.Name)) { throw new SampleNameIsUsedException(); } return(_sampleRepository.Create(sample)); }
public ActionResult Post(Resource resource) { var r = GetSampleResource(_repository.Create(resource.As <MySampleValue>())); return(Created(r.GetSelf().Href, r)); }