/// <summary> /// 楼栋信息添加 /// </summary> /// <param name="inputEntity"></param> /// <returns></returns> public bool DTOAdd(FloorInfoInputDTO inputEntity) { FloorInfo dataModel = Mapper.Map <FloorInfoInputDTO, FloorInfo>(inputEntity); if (floorInfoDAL.AddAndSaveChange(dataModel) > 0) { return(true); } else { return(false); } }
/// <summary> /// 添加方法 /// </summary> /// <param name="model"></param> /// <returns></returns> public string FloorInfoAdd(string FloorInfoJson) { //添加数据 //Json转实体类 FloorInfoInputDTO floorInfo = JsonConvert.DeserializeObject <FloorInfoInputDTO>(FloorInfoJson); if (FloorInfoService.DTOAdd(floorInfo)) { return("ok"); } else { return("no"); } }
/// <summary> /// 修改方法 /// </summary> /// <param name="model"></param> /// <returns></returns> public string FloorInfoUpdate(string FloorInfoJson) { int outID; //添加数据 //Json转实体类 FloorInfoInputDTO floorInfo = JsonConvert.DeserializeObject <FloorInfoInputDTO>(FloorInfoJson); if (FloorInfoService.DTOUpdate(floorInfo, out outID) > 0) { return("ok"); } else { return("no"); } }
/// <summary> /// 楼栋信息修改 /// </summary> /// <param name="inputEntity"></param> /// <param name="outID"></param> /// <returns></returns> public int DTOUpdate(FloorInfoInputDTO inputEntity, out int outID) { //先查 outID = 0; FloorInfo model = floorInfoDAL.LoadEntities(u => u.FloorID == inputEntity.FloorID).AsNoTracking().FirstOrDefault(); if (model != null) { // AutoMapper转换 FloorInfo dataModel = Mapper.Map <FloorInfoInputDTO, FloorInfo>(inputEntity); //修改数据 dataModel.ID = model.ID; outID = model.ID; return(floorInfoDAL.EditAndSaveChange(dataModel)); } else { return(0); } }