示例#1
0
        public void Save(Data.GoodiesGroup entity, string parentUniquePath)
        {
            try
            {
                if (entity.ID == Guid.Empty)
                {
                    entity.ID       = Guid.NewGuid();
                    entity.LastEdit = DateTime.Now;
                    this.Table.Add(entity);
                }
                else
                {
                    var view = this.GetViewById(entity.ID);
                    if (view.Code != entity.Code)
                    {
                        if (HasChild(entity))
                        {
                            throw new Exception(Localize.ex_invalid_code_changing);
                        }
                        entity.LastEdit = DateTime.Now;
                    }
                }

                entity.uniquepath = string.Format("{0}{1}{2}", parentUniquePath, Common.Constants.Seperators.UniquePath, entity.ID);

                this.SubmitChanges();
            }
            catch
            {
                throw;
            }
        }
示例#2
0
 public bool IsNameExist(Data.GoodiesGroup entity)
 {
     try
     {
         return(this.GetAll().Any(r => r.CName == entity.CName && r.ID != entity.ID));
     }
     catch
     {
         throw;
     }
 }
示例#3
0
 private bool HasChild(Data.GoodiesGroup entity)
 {
     try
     {
         return((entity.CodeTitleId == Common.Constants.CodeTitle.CommodityMainGroup && this.GetByParentId(entity.ID).Any()) ||
                (entity.CodeTitleId == Common.Constants.CodeTitle.CommoditySubsidiaryGroup && Business.GetGoodiesBusiness().GetByIdGoodiesGroup(entity.ID).Any()));
     }
     catch
     {
         throw;
     }
 }