コード例 #1
0
 public static void Update(BarangayProfileData data)
 {
     using (var db = new BrgyMgmtEntities()) {
         foreach (PropertyInfo prop in data.GetType().GetProperties())
         {
             ConfigData item = db.ConfigData.Where(x => x.ConfigName == prop.Name).SingleOrDefault();
             item.ConfigValue = prop.GetValue(data, null).ToString() ?? item.ConfigValue;
         }
         db.SaveChanges();
     }
 }
コード例 #2
0
        public static BarangayProfileData Get()
        {
            BarangayProfileData profile = new BarangayProfileData();

            using (var db = new BrgyMgmtEntities()) {
                profile.BarangayName = (db.ConfigData.Where(x => x.ConfigName == "BarangayName").SingleOrDefault()).ConfigValue;
                profile.Municipality = (db.ConfigData.Where(x => x.ConfigName == "Municipality").SingleOrDefault()).ConfigValue;
                profile.Province     = (db.ConfigData.Where(x => x.ConfigName == "Province").SingleOrDefault()).ConfigValue;
                profile.ZIP          = (db.ConfigData.Where(x => x.ConfigName == "ZIP").SingleOrDefault()).ConfigValue;
                profile.Slogan1      = (db.ConfigData.Where(x => x.ConfigName == "Slogan1").SingleOrDefault()).ConfigValue;
                profile.Slogan2      = (db.ConfigData.Where(x => x.ConfigName == "Slogan2").SingleOrDefault()).ConfigValue;
                profile.History      = (db.ConfigData.Where(x => x.ConfigName == "History").SingleOrDefault()).ConfigValue;
                profile.Demographics = (db.ConfigData.Where(x => x.ConfigName == "Demographics").SingleOrDefault()).ConfigValue;
                //profile.Logo = (db.ConfigData.Where(x => x.ConfigName == "Logo").SingleOrDefault()).ConfigValue;
                //var properties = TypeDescriptor.GetProperties(typeof(Models.BarangayProfile));
                //foreach (PropertyDescriptor property in properties) {
                //    var val = db.UnitDetails.Where(x => x.UnitName == property.Name);
            }

            return(profile);
        }