public override void OnRegister()
        {
            base.OnRegister();

            if (InstanceMap != null && !InstanceMap.Deleted)
            {
                InstanceMap.AddRegion(this, false);
            }

            AllRegions.AddOrReplace(this);
        }
Example #2
0
        private void OnRegionsLoaded(DataLoaded <Region> e)
        {
            foreach (var region in e.Data)
            {
                var viewmodel = new RegionViewModel(region);
                AllRegions.Add(viewmodel);

                //viewmodel.Exists();
                viewmodel.AddToUI(Overlay);
            }
        }
        public override void OnUnregister()
        {
            base.OnUnregister();

            if (InstanceMap != null)
            {
                InstanceMap.RemoveRegion(this, false);
            }

            AllRegions.Remove(this);
            AllRegions.Free(false);
        }
Example #4
0
            protected override ValidationResult IsValid(object value, ValidationContext validationContext)
            {
                var s = value as string;

                if (string.IsNullOrEmpty(s))
                {
                    return(new ValidationResult("Region is required"));
                }
                return(AllRegions.Contains(s, StringComparer.OrdinalIgnoreCase)
                    ? ValidationResult.Success
                    : new ValidationResult("Invalid Region"));
            }
Example #5
0
        private void CommitRegion()
        {
            if (EditingRegion != null)
            {
                lock (AllRegions) {
                    AllRegions.Add(EditingRegion);
                }

                EditingRegion.Commit();
                System.Diagnostics.Debug.WriteLine(JsonConvert.SerializeObject(EditingRegion));
                EditingRegion = null;
            }
        }
Example #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                RegionController sysmgr = new RegionController();
                List <Region>    info   = sysmgr.ListAllRegions();

                AllRegions.DataSource = info;
                AllRegions.DataBind();

                RegionsDDL.DataSource     = info;
                RegionsDDL.DataValueField = "RegionID";
                RegionsDDL.DataTextField  = "RegionDescription";
                RegionsDDL.DataBind();
            }
        }
Example #7
0
 public static void AddRegion(Region r)
 {
     AllRegions.Add(r);
     AppDb.Regions.Add(r);
     AppDb.SaveChanges();
 }
Example #8
0
 public RegionViewModel GetRegion(string name)
 {
     name = name.ToLower();
     return(AllRegions.FirstOrDefault(each => each.Name.ToLower() == name));
 }