public ModelView.ModifyResult <HotelUser> UpdateStatusAfterTransaction(IConnectionHandler connectionHandler, IConnectionHandler paymentConnection, Guid userId, Guid tempId) { HotelUserBO hotelUserBo = new HotelUserBO(); var result = new ModelView.ModifyResult <HotelUser>(); bool informUser = false; List <HotelUser> shopUser = hotelUserBo.Where(connectionHandler, x => x.TempId == tempId); if (!shopUser.Any()) { return(result); } Transaction tr = PaymentComponenets.Instance.TempTransactionalFacade(connectionHandler).RemoveTempAndReturnTransaction(tempId); if (tr == null) { return(result); } foreach (HotelUser hotelUser in shopUser) { hotelUser.TransactionId = tr.Id; hotelUser.TempId = null; if (tr.PreDone) { hotelUser.Status = (byte)Enums.RezervState.Pay; } if (!hotelUserBo.Update(connectionHandler, hotelUser)) { throw new Exception(Resources.Congress.ErrorInReservWorkShop); } } HotelUser hotel = shopUser.FirstOrDefault(); if (hotel != null) { if (tr.PreDone) { result.AddInform(new HotelUser() { HotelId = hotel.HotelId, UserId = userId }, Resources.Congress.HotelPaymentEmail, Resources.Congress.HotelPaymentSMS); result.SendInform = true; } } result.TransactionId = tr.Id; return(result); }
private bool DailyEvaulationForConfig(IConnectionHandler connectionHandler, Configuration configuration, Tools.ModelView.ModifyResult <UserBooth> keyValuePairs, Tools.ModelView.ModifyResult <WorkShopUser> workShopUsers, Tools.ModelView.ModifyResult <HotelUser> hotelUsers) { bool result; var userBoothBo = new UserBoothBO(); if (configuration.DayCountDeleteBoothReserveNotPay != null && configuration.DayCountDeleteBoothReserveNotPay > 0) { var list = userBoothBo.Where(connectionHandler, x => x.Booth.CongressId == configuration.CongressId && x.TransactionId == null); foreach (var userBooth in list) { var dateTime = DateTimeUtil.ShamsiDateToGregorianDate(userBooth.RegisterDate) .AddDays((double)configuration.DayCountDeleteBoothReserveNotPay) .ShamsiDate(); if (dateTime.CompareTo(DateTime.Now.ShamsiDate()) < 0) { if (!userBoothBo.Delete(connectionHandler, userBooth)) { throw new Exception(Resources.Congress.ErrorInWorkDailyScheduler); } keyValuePairs.AddInform( userBooth, Resources.Congress.BoothChangeStatusEmail, Resources.Congress.BoothChangeStatusSMS ); } } } var hotelUserBo = new HotelUserBO(); if (configuration.DayCountDeleteHotelReserveNotPay != null && configuration.DayCountDeleteHotelReserveNotPay > 0) { var list = hotelUserBo.Where(connectionHandler, x => x.Hotel.CongressId == configuration.CongressId && x.TransactionId == null); foreach (var hotelUser in list) { var user = hotelUser; var dateTime = DateTimeUtil.ShamsiDateToGregorianDate(user.RegisterDate) .AddDays((double)configuration.DayCountDeleteHotelReserveNotPay) .ShamsiDate(); if (dateTime.CompareTo(DateTime.Now.ShamsiDate()) < 0) { if (!hotelUserBo.Delete(connectionHandler, hotelUser)) { throw new Exception(Resources.Congress.ErrorInWorkDailyScheduler); } if (hotelUsers.InformList.All(x => x.obj.UserId != user.UserId)) { hotelUsers.AddInform( user, Resources.Congress.HotelChangeStatusEmail, Resources.Congress.HotelChangeStatusSMS ); } if (!user.User.ParentId.HasValue || hotelUsers.InformList.Any(x => x.obj.UserId == user.User.ParentId)) { continue; } hotelUsers.AddInform( new HotelUser() { UserId = (Guid)user.User.ParentId, HotelId = user.HotelId, Status = user.Status }, Resources.Congress.HotelChangeStatusEmail, Resources.Congress.HotelChangeStatusSMS ); } } } var workShopUserBo = new WorkShopUserBO(); if (configuration.DayCountDeleteWorkShopReserveNotPay != null && configuration.DayCountDeleteWorkShopReserveNotPay > 0) { var list = workShopUserBo.Where(connectionHandler, x => x.WorkShop.CongressId == configuration.CongressId && x.TransactionId == null); foreach (var shopUser in list) { var workShopUser = shopUser; var addDays = DateTimeUtil.ShamsiDateToGregorianDate(workShopUser.RegisterDate) .AddDays((double)configuration.DayCountDeleteWorkShopReserveNotPay); var dateTime = addDays.ShamsiDate(); if (dateTime.CompareTo(DateTime.Now.ShamsiDate()) < 0) { if (!workShopUserBo.Delete(connectionHandler, shopUser)) { throw new Exception(Resources.Congress.ErrorInWorkDailyScheduler); } if (workShopUsers.InformList.All(x => x.obj.UserId != workShopUser.UserId)) { workShopUsers.AddInform( workShopUser, Resources.Congress.WorkShopChangeStatusEmail, Resources.Congress.WorkShopChangeStatusSMS ); } if (!workShopUser.User.ParentId.HasValue || workShopUsers.InformList.Any(x => x.obj.UserId == workShopUser.User.ParentId)) { continue; } workShopUsers.AddInform( new WorkShopUser() { UserId = (Guid)workShopUser.User.ParentId, WorkShopId = workShopUser.WorkShopId, Status = workShopUser.Status } , Resources.Congress.WorkShopChangeStatusEmail , Resources.Congress.WorkShopChangeStatusSMS ); } } } result = true; return(result); }