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();
            }
        }