Exemplo n.º 1
0
        // GET: /Specification/Edit
        public IActionResult Edit(Guid?id, string ActiveTab)
        {
            if (id == null)
            {
                return(RedirectToAction("List"));
            }

            // check if product specification exist
            var specicationEntity = _specificationService.GetSpecificationById(id ?? Guid.Empty);

            if (specicationEntity == null)
            {
                return(RedirectToAction("List"));
            }

            // map entity to view model
            var model = _mapper.Map <Specification, SpecificationCreateOrUpdateModel>(specicationEntity);

            model.ActiveTab = ActiveTab ?? model.ActiveTab;

            // add model to session
            Session.SetString(_sessionKey, JsonConvert.SerializeObject(model));

            return(View(model));
        }