public void SQLSpampleRepository_Should_Get_All_Samples() { ISampleRepository sut = GetInMemorySampleRepository(); List <SampleModel> samples = sampleInMemoryDb(); SampleModel savedSample1 = sut.Add(samples[0]); SampleModel savedSample2 = sut.Add(samples[1]); sut.GetAllSamples(); Assert.Equal(2, samples.Count); Assert.Equal(123, savedSample1.Donor_Count); Assert.Equal(5592, savedSample2.Donor_Count); }
public IActionResult Post(Sample sample) { var currentUserProfile = GetCurrentUserProfile(); sample.UserProfileId = currentUserProfile.Id; _sampleRepository.Add(sample); return(CreatedAtAction("Get", new { id = sample.Id }, sample)); }
public IActionResult Create([FromBody] Sample item) { if (item == null) { return(BadRequest()); } _context.Add(item); return(CreatedAtRoute("GetSample", new { id = item.Key }, item)); }
//Add new users public bool Add(List <SampleDTO> entity) { bool message = false; List <Sample> userList = new List <Sample>(); userList = Mapper.Map <List <Sample> >(entity); message = _SampleRepository.Add(userList); return(message); }
public async Task <string> Handle(SampleCommand request, CancellationToken cancellationToken) { var sample = new Sample(request.Name); var greeting = sample.Greeting(); _sampleRepository.Add(sample); await _mediator.DispatchDomainEventsAsync(sample); return(greeting); }
public void SQLSampleRepository_Get_Sample_By_Id() { ISampleRepository sut = GetInMemorySampleRepository(); List <SampleModel> samples = sampleInMemoryDb(); SampleModel savedSample1 = sut.Add(samples[0]); sut.GetSample(savedSample1.Id); Assert.Equal(123, savedSample1.Donor_Count); }
public void SQLSampleRepository_Should_Delete_Sample() { ISampleRepository sut = GetInMemorySampleRepository(); List <SampleModel> samples = sampleInMemoryDb(); sut.Add(samples[0]); Assert.Single(sut.GetAllSamples()); sut.Delete(samples[0].Id); Assert.Empty(sut.GetAllSamples()); }
public Task <bool> Handle(CreateSampleCommand request, CancellationToken cancellationToken) { var course = new Sample() { Name = request.Name, Description = request.Description, ImageUrl = request.ImageUrl }; _courseRepository.Add(course); return(Task.FromResult(true)); }
public void AddSample(Sample sample) { try { sample.CreatedDate = DateTime.UtcNow; _sampleRepository.Add(sample); _sampleRepository.Save(); } catch (Exception ex) { LogHelper.WriteExceptionLog(ex); } }
public void SQLSampleRepository_Should_Update_Sample() { ISampleRepository sut = GetInMemorySampleRepository(); List <SampleModel> samples = sampleInMemoryDb(); sut.Add(samples[0]); Assert.Equal("28/09/2020", samples[0].Last_Updated); samples[0].Last_Updated = "14/10/2020"; sut.Update(samples[0]); Assert.Equal("14/10/2020", samples[0].Last_Updated); }
public void SQLSampleRepository_Should_Add_Sample() { ISampleRepository sut = GetInMemorySampleRepository(); List <SampleModel> samples = sampleInMemoryDb(); SampleModel savedSample = sut.Add(samples[0]); Assert.Single(sut.GetAllSamples()); Assert.Equal("ME219 Endoscopic Biopsy", savedSample.Material_Type); Assert.Equal("28/09/2020", savedSample.Last_Updated); Assert.Equal("Phase II multicentre study", savedSample.Collection_Title); Assert.Equal(2203, savedSample.Collection_Id); }
public async Task <IActionResult> Create(SampleModel sample, int?page, int id) { var collections = _db.GetCollection(id); sample.Collection_Id = id; sample.Id = 0; _db.Add(sample); ViewBag.CollectionId = collections.Collection_Id; ViewBag.CollectionTitle = collections.Title; var samples = _db.GetAllSamples(); var pageNumber = page ?? 1; var sampleList = await samples.Where(m => m.Collection_Id == id).ToPagedListAsync(pageNumber, 5); return(View("Details", sampleList)); }
public void CreateSample(Sample Sample) { SamplesRepository.Add(Sample); SaveSample(); }
public void Add(Sample sampleInstance) { _repository.Add(sampleInstance); }