コード例 #1
0
        public static void UpdateVolunteerAndFamily(Common.VolunteerAndFamily vaf)
        {
            VolunteerAndFamily g = Mapper.CastVolunteerAndFamily(vaf);

            using (dbRamotEntities db = new dbRamotEntities())
            {
                db.Entry <VolunteerAndFamily>(db.Set <VolunteerAndFamily>().Find(g.Id)).CurrentValues.SetValues(g);
                db.SaveChanges();
            }
        }
コード例 #2
0
 internal static Common.VolunteerAndFamily CastVolunteerAndFamilyToComon(VolunteerAndFamily vaf)
 {
     return(vaf == null ? null : new Common.VolunteerAndFamily()
     {
         Id = vaf.Id,
         Category = Mapper.CastCategoryToCommon(vaf.Categories),
         Family = Mapper.CastFamilyToComon(vaf.Families),
         Volunteer = Mapper.CastVolunteerToComon(vaf.Volunteers),
         Comments = vaf.Comments,
         DateAdded = vaf.dateAdded
     });
 }
コード例 #3
0
        public static void AddVolunteerAndFamily(Common.VolunteerAndFamily vaf)
        {
            VolunteerAndFamily g = Mapper.CastVolunteerAndFamily(vaf);

            using (dbRamotEntities db = new dbRamotEntities())
            { //if (db.VolunteerAndFamily.Contains(g))
                Categories c = null;
                if (vaf.Category != null)
                {
                    c = db.Categories.FirstOrDefault(ca => ca.Id == vaf.Category.Id);
                }
                var v = db.Volunteers.FirstOrDefault(ca => ca.Id == vaf.Volunteer.Id);
                var f = db.Families.FirstOrDefault(ca => ca.Id == vaf.Family.Id);
                g.Categories = c;
                g.Volunteers = v;
                g.Families   = f;
                db.VolunteerAndFamily.Add(g);
                db.SaveChanges();
            }
        }