示例#1
0
        public async Task <IHttpActionResult> Update(long labId, LabsEditViewModel model)
        {
            var(_, isLabManager) = await GetLab(labId);

            var lab = await LabsDao.Read(this, labId);

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

            var result = await LabsDao.Update(this, lab, model);

            return(JsonWithPermissions(result, User.IsPrivileged(), isLabManager, User.IsAdmin()));
        }
示例#2
0
        public async Task <ActionResult> Edit(Lab lab, LabsEditViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

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

            return(RedirectToAction("Details", new { lab = lab.LabId }));
        }