Example #1
0
        public ActionResult Create(LaboratorioEditViewModel laboratorioVm)
        {
            if (!ModelState.IsValid)
            {
                return(View(laboratorioVm));
            }

            LaboratorioEditDto laboratorioDto = _mapper.Map <LaboratorioEditDto>(laboratorioVm);

            if (_servicio.Existe(laboratorioDto))
            {
                ModelState.AddModelError(string.Empty, "Registro Existente...");
                return(View(laboratorioVm));
            }
            try
            {
                _servicio.Guardar(laboratorioDto);
                TempData["Msg"] = "Registro Agregado";
                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                ModelState.AddModelError(string.Empty, e.Message);
                return(View(laboratorioVm));
            }
        }