Пример #1
0
        public async Task <IHttpActionResult> AddReagent(long labId, long reagentId, int quantity = 1)
        {
            var(_, isLabManager) = await GetLab(labId);

            var result = await LabsDao.AddReagent(this, labId, reagentId, quantity);

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

            return(JsonWithPermissions(result, true, isLabManager, isLabManager));
        }
Пример #2
0
        public async Task <ActionResult> ConfirmAddReagent(Lab lab, Reagent reagent, LabsConfirmAddReagentViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

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

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