示例#1
0
 public async Task <IHttpActionResult> List(string query = null)
 {
     return(JsonWithPermissions(new
     {
         Results = await SamplesDao.Find(this, query)
     }));
 }
示例#2
0
        public async Task <ActionResult> ConfirmDelete(Sample sample)
        {
            if (sample != null)
            {
                await SamplesDao.Delete(this, sample);
            }

            return(RedirectToAction("Index"));
        }
示例#3
0
        public async Task <IHttpActionResult> Delete(int sampleId)
        {
            var result = await SamplesDao.Delete(this, sampleId);

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

            return(JsonWithPermissions(result));
        }
示例#4
0
        public async Task <IHttpActionResult> Update(int sampleId, SamplesEditViewModel model)
        {
            var sample = await SamplesDao.Read(this, sampleId);

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

            var result = await SamplesDao.Update(this, sample, model);

            return(JsonWithPermissions(result));
        }
示例#5
0
        public async Task <ActionResult> Index(string query = null)
        {
            if (string.IsNullOrWhiteSpace(query))
            {
                return(View(new SamplesSearchViewModel()));
            }

            var model = new SamplesSearchViewModel
            {
                Query   = query,
                Results = await SamplesDao.Find(this, query)
            };

            return(View(model));
        }
示例#6
0
        public async Task <ActionResult> Create(SamplesCreateViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            Sample sample;

            try
            {
                sample = await SamplesDao.Create(this, model);
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e);
                return(View(model));
            }

            return(RedirectToAction("Details", new { sample = sample.SampleId }));
        }
示例#7
0
        public async Task <ActionResult> Edit(Sample sample, SamplesEditViewModel model)
        {
            if (sample == null)
            {
                return(HttpNotFound());
            }

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            try
            {
                await SamplesDao.Update(this, sample, model);
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e);
                return(View(model));
            }

            return(RedirectToAction("Details", new { sample = sample.SampleId }));
        }
示例#8
0
 public async Task <IHttpActionResult> Create(SamplesCreateViewModel model)
 {
     return(JsonWithPermissions(await SamplesDao.Create(this, model)));
 }