public bool UpdateEntProperty(EnterprisePropertyDto enterpriseProperty)
 {
     try
     {
         using (var db = new BCEnterpriseContext())
         {
             var temp = db.EnterprisePropertys.First(x => x.EnterprisePropertyID == enterpriseProperty.EnterprisePropertyID);
             if (null == temp)
             {
                 throw new KnownException("该对象不存在");
             }
             temp.Available = enterpriseProperty.Available;
             temp.Name      = enterpriseProperty.Name;
             if (db.SaveChanges() > 0)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        public ActionResult UpdateProp(PropertyNewModel model)
        {
            var result = new StandardJsonResult <string>();

            result.Try(() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }
                var dto = new EnterprisePropertyDto {
                    EnterprisePropertyID = model.EnterprisePropertyID, Name = model.Name, Available = model.Available
                };

                bool value   = _service.UpdateEntProperty(dto);
                result.Value = value.ToString();
            });
            return(result);
        }
        public ActionResult AddProp(PropertyNewModel model)
        {
            //NewUserModel tempModel = Serializer.FromJson<NewUserModel>(jsonstr);
            var result = new StandardJsonResult <string>();

            result.Try(() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }

                var dto = new EnterprisePropertyDto {
                    EnterprisePropertyID = model.EnterprisePropertyID, Name = model.Name, Available = model.Available
                };

                string uid   = _service.AddEnterpriseProperty(dto);
                result.Value = uid;
            });
            return(result);
        }
        public string AddEnterpriseProperty(EnterprisePropertyDto enterpriseProperty)
        {
            try
            {
                using (var db = new BCEnterpriseContext())
                {
                    if (db.EnterprisePropertys.Any(n => n.Name.Equals(enterpriseProperty.Name)))
                    {
                        throw new KnownException("已存在该名字");
                    }
                    if (string.IsNullOrEmpty(enterpriseProperty.Name) || string.IsNullOrEmpty(enterpriseProperty.EnterprisePropertyID))
                    {
                        throw new KnownException("信息不完善");
                    }

                    var property = new ML.BC.EnterpriseData.Model.EnterpriseProperty
                    {
                        Available            = enterpriseProperty.Available,
                        EnterprisePropertyID = enterpriseProperty.EnterprisePropertyID,
                        Name = enterpriseProperty.Name
                    };
                    db.EnterprisePropertys.Add(property);
                    if (db.SaveChanges() > 0)
                    {
                        return(property.EnterprisePropertyID);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }