コード例 #1
0
        public async Task <IHttpActionResult> Update(int reagentId, ReagentsEditViewModel model)
        {
            var reagent = await ReagentsDao.Read(this, reagentId);

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

            var result = await ReagentsDao.Update(this, reagent, model);

            return(JsonWithPermissions(result));
        }
コード例 #2
0
        public async Task <ActionResult> Edit(Reagent reagent, ReagentsEditViewModel model)
        {
            if (reagent == null)
            {
                return(HttpNotFound());
            }

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

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

            return(RedirectToAction("Details", new { reagent = reagent.ReagentId }));
        }