Exemple #1
0
        public static void UpdateOrganizationAndFamily(Common.OrganizationAndFamily oaf)
        {
            OrganizationAndFamily g = Mapper.CastOrganizationAndFamily(oaf);

            using (dbRamotEntities db = new dbRamotEntities())
            {
                db.Entry <OrganizationAndFamily>(db.Set <OrganizationAndFamily>().Find(g.Id)).CurrentValues.SetValues(g);
                db.SaveChanges();
            }
        }
Exemple #2
0
        public static void AddOrganizationAndFamily(Common.OrganizationAndFamily oaf)
        {
            OrganizationAndFamily g = Mapper.CastOrganizationAndFamily(oaf);

            using (dbRamotEntities db = new dbRamotEntities())
            {
                Categories c = null;
                if (oaf.Category != null)
                {
                    c = db.Categories.FirstOrDefault(ca => ca.Id == oaf.Category.Id);
                }
                var f = db.Families.FirstOrDefault(ca => ca.Id == oaf.Family.Id);
                var o = db.Organization.FirstOrDefault(ca => ca.Id == oaf.Organization.Id);
                g.Categories   = c;
                g.Families     = f;
                g.Organization = o;
                db.OrganizationAndFamily.Add(g);
                db.SaveChanges();
            }
        }
Exemple #3
0
 internal static Common.OrganizationAndFamily CastOrganizationAndFamilyToComon(OrganizationAndFamily oaf)
 {
     return(oaf == null ? null : new Common.OrganizationAndFamily()
     {
         Id = oaf.Id,
         Category = CastCategoryToCommon(oaf.Categories),
         Family = CastFamilyToComon(oaf.Families),
         Organization = CastOrganizationToComon(oaf.Organization),
         Comments = oaf.Comments,
         DateAdded = oaf.dateAdded
     });
 }