public ActionResult Edit(CodeModel model)
        {
            var code = _codeRepository.GetById(model.Id);

            if (ModelState.IsValid)
            {
                code = model.ToEntity(code);
                if (model.ParentId > 0)
                {
                    var parentCode = _codeRepository.GetById(model.ParentId);
                    if (parentCode.CodeType == "Failure Group")
                    {
                        code.CodeType = "Problem";
                    }
                    if (parentCode.CodeType == "Problem")
                    {
                        code.CodeType = "Cause";
                    }
                    if (parentCode.CodeType == "Cause")
                    {
                        code.CodeType = "Resolution";
                    }
                }
                else
                {
                    code.CodeType = "Failure Group";
                }

                //always set IsNew to false when saving
                code.IsNew = false;
                //update attributes
                _codeRepository.Update(code);

                //commit all changes
                this._dbContext.SaveChanges();

                //notification
                SuccessNotification(_localizationService.GetResource("Record.Saved"));
                return(new NullJsonResult());
            }
            else
            {
                return(Json(new { Errors = ModelState.SerializeErrors() }));
            }
        }