public PropertyValueEntity GetOrCreatEntityWithValue(string value,PropertyEntity property) { try { var valueEntity = _propertyvalueRepository.Table.FirstOrDefault(c => c.Value == value && c.Property.Id == property.Id); if (valueEntity == null) { valueEntity = new PropertyValueEntity { Addtime = DateTime.Now, Adduser = (UserBase)_workContext.CurrentUser, Property = property, UpdUser = (UserBase)_workContext.CurrentUser, UpdTime = DateTime.Now, Value = value }; _propertyvalueRepository.Insert(valueEntity); } return valueEntity; } catch (Exception e) { _log.Error(e, "数据库操作出错"); return null; } }
public bool Delete(PropertyValueEntity entity) { try { _propertyvalueRepository.Delete(entity); return true; } catch (Exception e) { _log.Error(e,"数据库操作出错"); return false; } }
public PropertyValueEntity Create(PropertyValueEntity entity) { try { _propertyvalueRepository.Insert(entity); return entity; } catch (Exception e) { _log.Error(e,"数据库操作出错"); return null; } }
public bool Post(PropertyValueModel model) { var entity = new PropertyValueEntity { // Property = model.Property, Value = model.Value, Adduser = (UserBase)_workContext.CurrentUser, Addtime = DateTime.Now, UpdUser = (UserBase)_workContext.CurrentUser, UpdTime = DateTime.Now, }; if(_propertyValueService.Create(entity).Id > 0) { return true; } return false; }