/// <summary> /// </summary> /// <param name="dao"></param> /// <exception cref="ArgumentNullException">dao is null.</exception> public void Save(IOrgDao dao) { if (dao == null) { throw new ArgumentNullException("dao"); } Org ug = !String.IsNullOrEmpty(Id) ? dao.Get(Id) : new Org(Name); ug.Name = Name; ug.Remarks = Remark; dao.SaveOrUpdate(ug); dao.Flush(); if (Parent != null) { IOrgCollection list = Parent.Childs; list.Add(ug); dao.SaveOrUpdate(Parent); } }
public static Org CreateRootOrg(string name, string remark) { IOrgDao orgDao = OrnamentContext.DaoFactory.MemberShipFactory.CreateOrgDao(); Org org = orgDao.GetRootOrgBy(name) ?? new Org(name) { Remarks = remark }; orgDao.SaveOrUpdate(org); return(org); }
public static Org CreateOrg(string name, string remark, Org parent) { IOrgDao orgDao = OrnamentContext.DaoFactory.MemberShipFactory.CreateOrgDao(); Org org = orgDao.GetByName(name, parent) ?? new Org(name) { Remarks = remark }; parent.Childs.Add(org); orgDao.SaveOrUpdate(org); return(org); }
/// <summary> /// </summary> /// <param name="dao"></param> /// <exception cref="ArgumentNullException">dao is null.</exception> public void Save(IOrgDao dao) { if (dao == null) throw new ArgumentNullException("dao"); Org ug = !String.IsNullOrEmpty(Id) ? dao.Get(Id) : new Org(Name); ug.Name = Name; ug.Remarks = Remark; dao.SaveOrUpdate(ug); dao.Flush(); if (Parent != null) { IOrgCollection list = Parent.Childs; list.Add(ug); dao.SaveOrUpdate(Parent); } }