예제 #1
0
        public static SiteGroupSite SiteGroupSite(System.Data.IDataReader reader)
        {
            SiteGroupSite result = null;

            if (null != reader && reader.Read())
            {
                result = new SiteGroupSite();
                PopulateSiteGroupSite(result, reader);
            }

            return result;
        }
예제 #2
0
        public static void PopulateSiteGroupSite(SiteGroupSite input, System.Data.IDataReader reader)
        {
            PopulateRecord(input, reader);
            input.RecordId = input.SiteGroupSiteId = Utilities.ToInt(reader[Mimosa.Apartment.Common.SiteGroupSite.ColumnNames.SiteGroupSiteId]);
            input.SiteGroupId = Utilities.ToInt(reader[Mimosa.Apartment.Common.SiteGroupSite.ColumnNames.SiteGroupId]);
            input.SiteId = Utilities.ToInt(reader[Mimosa.Apartment.Common.SiteGroupSite.ColumnNames.SiteId]);

            input.SiteName = Utilities.ToString(reader[Mimosa.Apartment.Common.SiteGroupSite.ColumnNamesExtended.SiteName]);
            input.GroupName = Utilities.ToString(reader[Mimosa.Apartment.Common.SiteGroupSite.ColumnNamesExtended.GroupName]);
        }
예제 #3
0
 public static void SaveSiteGroups(List<SiteGroup> saveList)
 {
     if (saveList != null)
     {
         foreach (SiteGroup item in saveList)
         {
             if (item.IsDeleted && item.NullableRecordId != null)
             {
                 DeleteRecord((Record)item);
             }
             else if (item.IsChanged)
             {
                 SaveRecord((Record)item);
                 if (item.SiteGroupId > 0) //update
                 {
                     List<SiteGroupSite> sgsList = ListSiteGroupSite(item.SiteGroupId, null);
                     foreach (SiteGroupSite sgs in sgsList)
                     {
                         if (item.Sites == null || item.Sites.Count(i => i.SiteId == sgs.SiteId) == 0)
                         {
                             DeleteRecord((Record)sgs);
                         }
                     }
                     if (item.Sites != null)
                     {
                         foreach (Site site in item.Sites)
                         {
                             if (sgsList.Count(i => i.SiteId == site.SiteId) == 0)
                             {
                                 SiteGroupSite newSGS = new SiteGroupSite();
                                 newSGS.SiteGroupId = item.SiteGroupId;
                                 newSGS.SiteId = site.SiteId;
                                 newSGS.CreatedBy = newSGS.UpdatedBy = item.UpdatedBy;
                                 SaveRecord((Record)newSGS);
                             }
                         }
                     }
                 }
                 else
                 {
                     item.SiteGroupId = Convert.ToInt32(item.RecordId);
                     if (item.Sites != null)
                     {
                         foreach (Site site in item.Sites)
                         {
                             SiteGroupSite newSGS = new SiteGroupSite();
                             newSGS.SiteGroupId = item.SiteGroupId;
                             newSGS.SiteId = site.SiteId;
                             newSGS.CreatedBy = newSGS.UpdatedBy = item.UpdatedBy;
                             SaveRecord((Record)newSGS);
                         }
                     }
                 }
             }
         }
     }
 }