Example #1
0
        public static DBR.Restroom ToEntity(Dto.Restroom restroom)
        {
            if (restroom == null)
            {
                return(null);
            }

            var newRestroom = new DBR.Restroom
            {
                RestroomId             = restroom.RestroomId,
                ContactId              = restroom.ContactId == 0 ? null : restroom.ContactId,
                EquipmentNum           = restroom.EquipmentNum,
                RestroomType           = restroom.RestroomType,
                RestroomName           = restroom.RestroomName,
                Address                = restroom.Address,
                City                   = restroom.City,
                State                  = restroom.State,
                Zip                    = restroom.Zip,
                Country                = restroom.Country,
                DrinkingWater          = restroom.DrinkingWater,
                WeekdayHours           = restroom.WeekdayHours,
                SaturdayHours          = restroom.SaturdayHours,
                SundayHours            = restroom.SundayHours,
                Note                   = restroom.Note,
                NearestIntersection    = restroom.NearestIntersection,
                LongDec                = restroom.LongDec,
                LatDec                 = restroom.LatDec,
                NotificationEmail      = restroom.NotificationEmail,
                CleanedContactId       = restroom.CleanedContactId == 0 ? null : restroom.CleanedContactId,
                RepairedContactId      = restroom.RepairedContactId == 0 ? null : restroom.RepairedContactId,
                SuppliedContactId      = restroom.SuppliedContactId == 0 ? null : restroom.SuppliedContactId,
                SecurityGatesContactId = restroom.SecurityGatesContactId == 0 ? null : restroom.SecurityGatesContactId,
                SecurityLocksContactId = restroom.SecurityLocksContactId == 0 ? null : restroom.SecurityLocksContactId,
                IsToiletAvailable      = restroom.IsToiletAvailable,
                //Active = restroom.Active,
                ToiletGenderId  = restroom.ToiletGenderId,
                AddressChanged  = restroom.AddressChanged,
                LabelId         = restroom.LabelId,
                StatusListId    = restroom.StatusListId,
                Deleted         = restroom.Deleted,
                IsHistory       = restroom.IsHistory,
                IsPublic        = restroom.IsPublic,
                UnavailableFrom = restroom.UnavailableFrom,
                UnavailableTo   = restroom.UnavailableTo,
                Comment         = restroom.Comment
            };

            //Create geography object for the current location
            newRestroom.Geo = System.Data.Entity.Spatial.DbGeography.PointFromText(
                $"POINT({restroom.LongDec} {restroom.LatDec})", 4326);

            //Transform string array of routes into a comma separated values string
            if (restroom.SelectedRoutes != null && restroom.SelectedRoutes.Count() > 0)
            {
                newRestroom.ACTRoute = string.Join(",", restroom.SelectedRoutes);
            }
            else
            {
                newRestroom.ACTRoute = restroom.ACTRoute;
            }

            return(newRestroom);
        }
Example #2
0
        public static Dto.Restroom ToModel(IRestroom restroom)
        {
            if (restroom == null)
            {
                return(null);
            }

            var newRestroom = new Dto.Restroom
            {
                RestroomId             = restroom.RestroomId,
                ContactId              = restroom.ContactId ?? 0,
                EquipmentNum           = restroom.EquipmentNum,
                RestroomType           = restroom.RestroomType,
                RestroomName           = restroom.RestroomName,
                Address                = restroom.Address,
                City                   = restroom.City,
                State                  = restroom.State,
                Zip                    = restroom.Zip,
                Country                = restroom.Country,
                DrinkingWater          = restroom.DrinkingWater,
                ACTRoute               = restroom.ACTRoute,
                WeekdayHours           = restroom.WeekdayHours,
                SaturdayHours          = restroom.SaturdayHours,
                SundayHours            = restroom.SundayHours,
                Note                   = restroom.Note,
                NearestIntersection    = restroom.NearestIntersection,
                LongDec                = restroom.LongDec,
                LatDec                 = restroom.LatDec,
                Geo                    = restroom.Geo,
                NotificationEmail      = restroom.NotificationEmail,
                CleanedContactId       = restroom.CleanedContactId,
                RepairedContactId      = restroom.RepairedContactId,
                SuppliedContactId      = restroom.SuppliedContactId,
                SecurityGatesContactId = restroom.SecurityGatesContactId,
                SecurityLocksContactId = restroom.SecurityLocksContactId,
                IsToiletAvailable      = restroom.IsToiletAvailable,
                //Active = restroom.Active,
                ToiletGenderId  = restroom.ToiletGenderId,
                AddressChanged  = restroom.AddressChanged ?? false,
                LabelId         = restroom.LabelId,
                Deleted         = restroom.Deleted,
                IsHistory       = restroom.IsHistory,
                IsPublic        = restroom.IsPublic,
                UnavailableFrom = restroom.UnavailableFrom,
                UnavailableTo   = restroom.UnavailableTo,
                Comment         = null,
                StatusListId    = restroom.StatusListId ?? (int)RestroomEnums.RestroomApprovalStatus.Pending
            };

            //Look for specific properties for restroom class variations

            /*if (restroom is IPendingReview review)
             *  newRestroom.PendingReview = review.PendingReview;*/

            if (restroom is IRestroomModifier modifier)
            {
                newRestroom.AddUserName = modifier.AddUserName;
                newRestroom.UpdUserName = modifier.UpdUserName;
            }

            if (restroom is IHistoryVersion version)
            {
                newRestroom.SysStartTime = version.SysStartTime;
                newRestroom.SysEndTime   = version.SysEndTime;
            }

            if (restroom is IAuditableEntity audit)
            {
                newRestroom.AddUserId   = audit.AddUserId;
                newRestroom.AddDateTime = audit.AddDateTime;
                newRestroom.UpdUserId   = audit.UpdUserId;
                newRestroom.UpdDateTime = audit.UpdDateTime;
            }

            return(newRestroom);
        }