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())); }
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 })); }