コード例 #1
0
        public bool ValidateBeforeSave(out string validationError)
        {
            bool isvalid = true;

            validationError = "";
            foreach (var trip in _context.ManagedEntities <Trip>())
            {
                isvalid = trip.ValidateBeforeSave(out validationError);
            }
            return(isvalid);
        }
コード例 #2
0
        private bool ValidateTrips(out string message)
        {
            var    trips = _context.ManagedEntities <Trip>().Where(t => t.EntityState == System.Data.EntityState.Added);
            string tD;

            foreach (var trip in trips)
            {
                //get trip details from TripsWIthDetail
                if (trip.Destination != null)
                {
                    tD = trip.TripDetails;
                }
                else
                {
                    message = "There is a new trip with no destination selected. Please fix this.";

                    return(false);
                }

                if (trip.LodgingID == 0 || trip.DestinationID == 0)
                {
                    message = tD + ": You must select a Lodging and a Destination.";
                    return(false);
                }
                if (trip.StartDate < DateTime.Today)
                {
                    message = tD + ": The Start Date must be in the future";
                    return(false);
                }
                if (trip.EndDate < trip.StartDate)
                {
                    message = tD + ": The End Date must be later than the start date";
                    return(false);
                }
            }

            message = "";
            return(true);
        }