public Hotels GetHotel(int id, string userName) { var users = CustomerInfoList.FirstOrDefault(x => x.EmailAddress == userName); Hotels hotels; if (users != null && users.IsSuperAdmin) { hotels = GetAll().FirstOrDefault(x => x.HotelId == id); } else { hotels = (from p in HotelList join p1 in UserHotelList on p.HotelId equals p1.HotelId join p2 in CustomerInfoList on p1.CustomerId equals p2.CustomerId where p.HotelId == id && p2.EmailAddress == userName && p2.IsAdmin select p).FirstOrDefault(); } if (hotels != null) { SetHotelData(ref hotels, hotels.HotelId); } return(hotels); }
public SearchDataResponse SearchData() { var result = new SearchDataResponse { ListBookings = DayaxeDbContext.Bookings.OrderByDescending(x => x.BookingId).ToList(), ListCustomerInfos = CustomerInfoList.Where(c => !c.IsDelete).ToList() }; result.ListBookings.ForEach(booking => { var product = ProductList.FirstOrDefault(p => p.ProductId == booking.ProductId); var hotel = HotelList.FirstOrDefault(h => h.HotelId == (product != null ? product.HotelId : 0)); booking.BookingsTypeString = product != null ? GetProductType(product.ProductType) : string.Empty; booking.TimeZoneId = hotel != null ? hotel.TimeZoneId : string.Empty; }); result.ListCustomerInfos.ForEach(customer => { var discount = GetSubscriptionDiscount(customer.CustomerId); if (discount != null) { customer.SubscriptionCode = discount.Code; } }); return(result); }
public List <Hotels> SearchHotelsByCode(bool isPublish = false, string code = "", int customerId = 0) { var hotels = GetAll().Where(x => !x.IsDelete).OrderByDescending(x => x.Order).ToList(); // if (!string.IsNullOrEmpty(code)) { hotels = hotels.Where(x => x.IsActive).ToList(); } // Has user login and admin if (customerId > 0) { var user = CustomerInfoList.FirstOrDefault(x => x.CustomerId == customerId && x.IsAdmin); if (user != null) { return(hotels.Where(x => x.IsActive).ToList()); } } // Publish use on client if (isPublish) { hotels = hotels.Where(x => x.IsPublished && x.IsActive).ToList(); } return(hotels.OrderBy(h => h.Order).ToList()); }
/// <summary> /// 获取数据 /// </summary> /// <returns></returns> public bool GetDataList() { string functionName = "GetDataList"; try { List <AMS.Model.AMS_AdCustomer> modellist = new List <Model.AMS_AdCustomer>(); modellist = AMS.ServiceProxy.IAdCustomerService.GetCustomerList(); CustomerInfoList.Clear(); foreach (AMS.Model.AMS_AdCustomer model in modellist) { CustomerInfoList.Add(model); } return(true); } catch (AMS.Model.CustomerException ex) { ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction); return(false); } catch (Exception ex) { ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName); return(false); } }
public List <Hotels> SearchHotelsByUserId(int userId) { var users = CustomerInfoList.FirstOrDefault(x => x.CustomerId == userId); if (users != null && users.IsSuperAdmin) { return((from p in HotelList where !p.IsDelete orderby p.Order descending select p).ToList()); } var hotels = from p in HotelList join p1 in UserHotelList on p.HotelId equals p1.HotelId join p2 in CustomerInfoList on p1.CustomerId equals p2.CustomerId where p2.CustomerId == userId && !p.IsDelete && p2.IsAdmin orderby p.Order select p; return(hotels.ToList()); }
private static void TestingCustomer() { //Customer obj = Customer.NewCustomer(); //obj.CustNo = ""; //obj.FirstName = "Anindya"; //obj.LastName = "Kurniawan"; //obj.Email = "*****@*****.**"; //obj.CompanyName = "Colony Digital"; //obj.CreatedBy = "Admin"; //obj.CreatedDate = DateTime.Now; //obj.UpdatedBy = obj.CreatedBy; //obj.UpdatedDate = obj.CreatedDate; ////obj = obj.Save(); //obj = Customer.GetCustomer(17); //obj.CustNo = "085640850840"; ////obj.Delete(); //obj = obj.Save(); CustomerInfoList infolist = CustomerInfoList.GetCustomerInfoList(); CustomerList list = CustomerList.GetCustomerList(); }
private void Listar() { try { Cursor = Cursors.WaitCursor; customerInfoListBindingSource.DataSource = CustomerInfoList.GetCustomerList(); customerInfoListBindingSource.ResetBindings(false); } catch (DataPortalException ex) { MessageBox.Show(ex.BusinessException.Message, "Listar", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } catch (Exception ex) { MessageBox.Show(ex.Message, "Listar", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { Cursor = Cursors.Default; } }
public IEnumerable <CustomerCreditLogs> GetAllLogsByCustomerId(long customerId) { var logs = GetAllLogs().Where(h => h.CustomerId == customerId).OrderByDescending(l => l.CreatedDate).ToList(); logs.ForEach(log => { var customerInfos = CustomerInfoList.FirstOrDefault(ci => ci.CustomerId == log.ReferralId); string fullName = string.Empty; if (customerInfos != null) { if (!string.IsNullOrEmpty(customerInfos.FirstName) && !string.IsNullOrEmpty(customerInfos.LastName)) { fullName = string.Format("{0} {1}", customerInfos.FirstName, customerInfos.LastName); } else { fullName = customerInfos.EmailAddress; } } log.Description = string.Format(log.Description, fullName); }); return(logs); }
public int Add(GiftCardBookings entity) { using (var transaction = new TransactionScope()) { var customerInfos = CustomerInfoList.FirstOrDefault(ci => ci.CustomerId == entity.CustomerId); var giftCard = new GiftCards { Amount = entity.TotalPrice, Code = string.Format(Constant.GiftCardFormat, entity.CustomerId, Helper.RandomString(7)), Name = string.Format(Constant.GiftCardNameFormat, customerInfos != null ? customerInfos.EmailAddress : entity.CustomerId.ToString(), entity.RecipientName, entity.RecipientEmail), IsDelete = false, Status = (byte)Enums.GiftCardType.Available }; DayaxeDbContext.GiftCards.InsertOnSubmit(giftCard); Commit(); entity.GiftCardId = giftCard.Id; DayaxeDbContext.GiftCardBookings.InsertOnSubmit(entity); Commit(); if (entity.PayByCredit > 0) { var creditLogs = new CustomerCreditLogs { Amount = entity.PayByCredit, CreatedBy = entity.CustomerId, CreatedDate = DateTime.UtcNow, CreditType = (byte)Enums.CreditType.Charge, Description = entity.Description, CustomerId = entity.CustomerId, Status = true, GiftCardId = entity.GiftCardId }; DayaxeDbContext.CustomerCreditLogs.InsertOnSubmit(creditLogs); var cusCredits = DayaxeDbContext.CustomerCredits .SingleOrDefault(cc => cc.CustomerId == entity.CustomerId); if (cusCredits != null) { cusCredits.Amount -= entity.PayByCredit; } } var schedulesAddOn = new Schedules { ScheduleSendType = (int)Enums.ScheduleSendType.IsEmailGiftCardConfirmation, Name = "Send eGift Card Confirmation", Status = (int)Enums.ScheduleType.NotRun, GiftCardBookingId = entity.Id }; DayaxeDbContext.Schedules.InsertOnSubmit(schedulesAddOn); Commit(); transaction.Complete(); return(entity.Id); } }