public JsonResult UpdateTrait(ComponentTraitDTO dto) { ComponentTraitDTO result = null; try { var entity = UnitOfWork.TblXTrait.Get(dto.ID); if (entity != null) { entity.trait_comp_id = dto.trait_comp_id; entity.trait_trait_id = dto.trait_trait_id; entity.tbl_trait = null; entity.tbl_comp = null; UnitOfWork.Save(); result = Mapper.Map <ComponentTraitDTO>(entity); } } catch (Exception ex) { _logger.Error(ex); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult AddTrait(ComponentTraitDTO dto) { ComponentTraitDTO result = null; try { var entity = Mapper.Map <tbl_X_trait>(dto); if (entity != null) { entity.tbl_trait = null; entity.tbl_comp = null; UnitOfWork.TblXTrait.Add(entity); UnitOfWork.Save(); result = Mapper.Map <ComponentTraitDTO>(entity); } } catch (Exception ex) { _logger.Error(ex); } return(Json(result, JsonRequestBehavior.AllowGet)); }