示例#1
0
        // <summary>
        // Add /Update Area
        // </summary>
        public Area SaveArea(Area area)
        {
            Area dbVersion = areaRepository.Find(area.AreaId);

            //Code Duplication Check
            if (areaRepository.DoesAreaCodeExist(area))
            {
                throw new CaresException(Resources.GeographicalHierarchy.Area.AreaCodeDuplicationError);
            }

            if (dbVersion != null)
            {
                UpdateAreaPropertie(area, dbVersion);
                areaRepository.Update(dbVersion);
            }
            else
            {
                dbVersion = new Area();
                SetAreaProperties(area, dbVersion);
                areaRepository.Add(dbVersion);
            }
            areaRepository.SaveChanges();
            // To Load the proprties
            return(areaRepository.LoadAreaWithDetail(dbVersion.AreaId));
        }