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; } }
public bool IsNameExist(Data.GoodiesGroup entity) { try { return(this.GetAll().Any(r => r.CName == entity.CName && r.ID != entity.ID)); } catch { throw; } }
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; } }