Exemplo n.º 1
0
 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;
     }
 }
Exemplo n.º 2
0
 public bool Delete(PropertyEntity entity)
 {
     try
     {
         _propertyRepository.Delete(entity);
         return true;
     }
     catch (Exception e)
     {
         _log.Error(e,"数据库操作出错");
         return false;
     }
 }
Exemplo n.º 3
0
 public PropertyEntity Create(PropertyEntity entity)
 {
     try
     {
         _propertyRepository.Insert(entity);
         return entity;
     }
     catch (Exception e)
     {
         _log.Error(e,"数据库操作出错");
         return null;
     }
 }
Exemplo n.º 4
0
        public bool Post(PropertyModel model)
        {
            var entity = new PropertyEntity
            {

                PropertyName = model.PropertyName,

                Adduser = (UserBase)_workContext.CurrentUser,

                Addtime = DateTime.Now,

                UpdUser = (UserBase)_workContext.CurrentUser,

                UpdTime = DateTime.Now,

            //				Value = model.Value,

                Category = _categoryService.GetCategoryById(model.Category.Id)

            };
            if(_propertyService.Create(entity).Id > 0)
            {
                return true;
            }
            return false;
        }