Exemplo n.º 1
0
        public static bool save_region(MS_SYS_REGIONS are)
        {
            var db        = new SibaModel();
            var dbRegions = db.MS_SYS_REGIONS.Find(are.REG_CODE);

            switch (are.REG_STATUS)
            {
            case "A":
            {
                if (dbRegions != null)
                {
                    db.MS_SYS_REGIONS.Attach(dbRegions);
                    dbRegions.Map(are);
                }
            }
            break;

            case "U":
                are.REG_STATUS = "A";
                db.MS_SYS_REGIONS.Add(are);
                break;

            case "D":
            {
                if (dbRegions != null)
                {
                    db.MS_SYS_REGIONS.Attach(dbRegions);
                    dbRegions.REG_STATUS = "D";
                }
            }
            break;
            }
            return(db.SaveChanges() > 0);
        }
Exemplo n.º 2
0
        public static bool update_region(MS_SYS_REGIONS regions)
        {
            var db        = new SibaModel();
            var dbRegions = db.MS_SYS_REGIONS.Find(regions.REG_CODE);

            if (dbRegions != null)
            {
                db.MS_SYS_REGIONS.Attach(dbRegions);
                dbRegions.Map(regions);
                return(db.SaveChanges() > 0);
            }
            return(false);
        }