public static void IsValid(TourPrice tourPrice, int?Id = null) { Exception ex = new Exception("Validate excption"); var inputDateRange = new DateRange(tourPrice.StartDate, tourPrice.EndDate); var tour = TourDAL.GetById(tourPrice.TourId); if (tour == null) { ex.Data.Add("Tour", "Không tìm thấy tour"); } var tourPrices = TourPriceDAL.Find(tp => (tp.TourId == tour.Id) && (!Id.HasValue || tp.Id != Id)); foreach (var x in tourPrices) { var sourceDateRange = new DateRange(x.StartDate, x.EndDate); if (!inputDateRange.BeforeOrAfter(sourceDateRange)) { ex.Data.Add("Thời gian", "Thời gian bắt đầu và kết thúc không hợp lệ"); break; } } if (ex.Data.Count > 0) { throw ex; } }
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; } }
public SliderEmp(TourDAL tourDAL, DestinationDAL destinationDAL, IConfiguration configuration) { this.tourDAL = tourDAL; this.destinationDAL = destinationDAL; this.logger = new LoggerConfiguration() .WriteTo.AzureBlobStorage(configuration["Data:StorageAccount"], Serilog.Events.LogEventLevel.Information, $"logs", "{yyyy}/{MM}/{dd}/log.txt").CreateLogger(); }
public CartController(Cart cart, TourDAL tourDAL, CouponDAL couponDAL, IConfiguration configuration) { this.cart = cart; this.tourDAL = tourDAL; this.couponDAL = couponDAL; this.logger = new LoggerConfiguration() .WriteTo.AzureBlobStorage(configuration["Data:StorageAccount"], Serilog.Events.LogEventLevel.Information, $"logs", "{yyyy}/{MM}/{dd}/log.txt").CreateLogger(); }
public NavigationBar(TourDAL tourDAL, UserManager <AppUser> userManager, Cart cart, IConfiguration configuration) { this.tourDAL = tourDAL; this.userManager = userManager; this.cart = cart; this.logger = new LoggerConfiguration() .WriteTo.AzureBlobStorage(configuration["Data:StorageAccount"], Serilog.Events.LogEventLevel.Information, $"logs", "{yyyy}/{MM}/{dd}/log.txt").CreateLogger(); }
public TourController(TourDAL tourDAL, DestinationDAL destinationDAL, UserManager <AppUser> userManager, BlobService blobService, Microsoft.Extensions.Configuration.IConfiguration configuration) { this.tourDAL = tourDAL; this.destinationDAL = destinationDAL; this.userManager = userManager; this.blobService = blobService; this.logger = new LoggerConfiguration() .WriteTo.AzureBlobStorage(configuration["Data:StorageAccount"], Serilog.Events.LogEventLevel.Information, $"logs", "{yyyy}/{MM}/{dd}/log.txt").CreateLogger(); }
public static void Delete(int id) { var sourceTour = TourDAL.GetById(id); if (sourceTour == null) { throw new Exception("Mã tour không tồn tại"); } TourDAL.Remove(sourceTour); }
public static void Update(Tour tour) { try { IsValid(tour, tour.Id); TourDAL.Update(tour); } catch (Exception ex) { throw ex; } }
public static void Add(Tour tour) { try { IsValid(tour); TourDAL.Add(tour); } catch (Exception ex) { throw ex; } }
public static IEnumerable <Tour> ListTours(string type = null, string value = null) { int valueInt; bool isNumeric = int.TryParse(value, out valueInt); return(TourDAL.Get( t => type == null || ( (type == "Id" && isNumeric && t.Id == valueInt) || (type == "Name" && t.Name.Contains(value.Trim())) || (type == "Description" && t.Description.Contains(value.Trim())) || (type == "TourTypeName" && t.TourType.Name.Contains(value.Trim())) ), null, new List <Expression <Func <Tour, object> > > { t => t.TourType } )); }
public static IEnumerable <TourWithGroups> ListTourWithGroups(DateTime?StartDate = null, DateTime?EndDate = null) { try { if (StartDate.HasValue && EndDate.HasValue) { new DateRange(StartDate.Value, EndDate.Value); } var listTours = TourDAL.Get(); var listTourWithGroups = listTours.Select(t => new TourWithGroups { Tour = t }).ToList(); //Check filter date in this listGroups; var listGroups = GroupDAL.Get( filter: g => (!StartDate.HasValue || !EndDate.HasValue) || (StartDate.Value <= g.StartDate && g.StartDate <= EndDate.Value), includeProperties: new List <Expression <Func <Group, object> > > { g => g.Tour, g => g.Costs, g => g.CustomerGroups, } ).ToList(); foreach (var group in listGroups) { int foundIndex = listTourWithGroups.FindIndex(ele => ele.Tour.Id == group.Tour.Id); if (foundIndex != -1) { listTourWithGroups[foundIndex].Groups.Add(group); } } return(listTourWithGroups); } catch (Exception ex) { throw ex; } }
public TourBLL() { tourDal = new TourDAL(); }