Beispiel #1
0
        public static RegionApiModel ToApi(this RegionModel model)
        {
            RegionApiModel res = new RegionApiModel();

            res.Iid  = model.Iid;
            res.Name = model.Name;
            return(res);
        }
        private RegionModel SaveOneRegion(RegionApiModel region, CompetitionModel comp)
        {
            var reg = db.Regions.FirstOrDefault(r => r.Name.Equals(region.Name, StringComparison.OrdinalIgnoreCase));

            if (reg != null)
            {
                return(reg);
            }
            String regName = region.Name.ToLowerInvariant();

            if (regName.Contains("респ"))
            {
                regName = regName.Replace("республика", String.Empty).Replace("респ.", String.Empty).Replace("респ", String.Empty);
            }
            else if (regName.Contains("обл."))
            {
                regName = regName.Replace("обл.", String.Empty);
            }
            else if (regName.Contains("область"))
            {
                regName = regName.Replace("область", String.Empty);
            }
            else if (regName.Contains("край"))
            {
                regName = regName.Replace("край", String.Empty);
            }
            else if (regName.Contains("кр."))
            {
                regName = regName.Replace("кр.", String.Empty);
            }
            regName = regName.Trim();
            reg     = db.Regions.ToList().FirstOrDefault(r => r.Name.ToLower().Contains(regName));
            if (reg != null)
            {
                return(reg);
            }
            reg = new RegionModel
            {
                IidParent = comp.Region.IidParent,
                Name      = region.Name,
                SymCode   = (comp.Region.IidParent == null ? String.Empty : comp.Region.Parent.SymCode) + (db.Regions.Max(r => r.Iid) + 1).ToString("0000")
            };
            db.Regions.Add(reg);
            return(reg);
        }
Beispiel #3
0
 public AsyncRequestResult BeginPostRegion(RegionApiModel region, RequestCompleted <RegionApiModel> callback, Object asyncState)
 {
     return(BeginPostSerializableT("Calendar", "PostTeam", String.Empty, region, callback, asyncState, true));
 }
Beispiel #4
0
 public RegionApiModel PostRegion(RegionApiModel region)
 {
     return(PostSerializableT("Calendar", "PostTeam", String.Empty, region));
 }