Exemple #1
0
        public async Task <ActionResult> PostRemoveSample(Lab lab, Sample sample)
        {
            if (sample == null)
            {
                return(HttpNotFound());
            }

            var labSample = await DbContext.LabSamples
                            .Include(ls => ls.Sample)
                            .FirstOrDefaultAsync(ls => ls.LabId == lab.LabId && ls.SampleId == sample.SampleId);

            if (labSample == null)
            {
                return(HttpNotFound());
            }

            try
            {
                await LabsDao.RemoveSample(this, lab.LabId, sample.SampleId);
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e);
                return(View("RemoveSample", new LabsRemoveSampleViewModel
                {
                    Lab = lab,
                    LabSample = labSample
                }));
            }

            return(RedirectToAction("Samples", new { lab = lab.LabId }));
        }
Exemple #2
0
        public async Task <IHttpActionResult> RemoveSample(long labId, long sampleId)
        {
            var result = await LabsDao.RemoveSample(this, labId, sampleId);

            if (result == null)
            {
                return(NotFound());
            }

            return(JsonWithPermissions(result, true, true, true));
        }