示例#1
0
        public static void IsValid(Tour tour, int?Id = null)
        {
            Exception ex = new Exception("Validate excption");

            if (String.IsNullOrWhiteSpace(tour.Name))
            {
                ex.Data.Add("Tên", "Tên tour không được bỏ trống");
            }
            if (String.IsNullOrWhiteSpace(tour.Description))
            {
                ex.Data.Add("Mô tả", "Mô tả không được bỏ trống");
            }
            if (tour.CurrentPrice < 0)
            {
                ex.Data.Add("Giá", "Giá tiền phải lớn 0");
            }
            if (TourTypeDAL.GetById(tour.TourTypeId) == null)
            {
                ex.Data.Add("Thể Loại Tour", "Thể loại tour không tồn tại");
            }
            if (TourDAL.Find(t => t.Name == tour.Name && (!Id.HasValue || t.Id != Id)).FirstOrDefault() != null)
            {
                ex.Data.Add("Tên", "Tên tour đã tồn tại");
            }
            if (ex.Data.Count > 0)
            {
                throw ex;
            }
        }
示例#2
0
 public static IEnumerable <TourType> ListTourTypes()
 {
     return(TourTypeDAL.Get());
 }