public ModelView.ModifyResult <UserBooth> UserBoothUpdate(IConnectionHandler connectionHandler, IConnectionHandler formGeneratorConnection, IConnectionHandler enterpriseNodeConnection, UserBooth userBooth, FormGenerator.DataStructure.FormStructure formModel, List <BoothOfficer> boothOfficers) { var modifyResult = new ModelView.ModifyResult <UserBooth>(); if ( !FormGeneratorComponent.Instance.FormDataTransactionalFacade(formGeneratorConnection) .ModifyFormData(formModel)) { throw new Exception(Resources.Congress.ErrorInSaveBoothReserv); } if (!Update(connectionHandler, userBooth)) { throw new Exception(Resources.Congress.ErrorInReservBooth); } if (boothOfficers != null && boothOfficers.Any()) { if (!new BoothOfficerBO().BoothOfficerModify(connectionHandler, enterpriseNodeConnection, boothOfficers, userBooth)) { return(modifyResult); } } modifyResult.Result = true; modifyResult.AddInform(userBooth, Resources.Congress.BoothUpdateEmail, Resources.Congress.BoothUpdateSMS); modifyResult.SendInform = true; return(modifyResult); }
public ModelView.ModifyResult <UserBooth> UserBoothInsert(IConnectionHandler connectionHandler, IConnectionHandler paymentConnection, IConnectionHandler formGeneratorConnection, IConnectionHandler enterpriseNodeConnection, UserBooth userBooth, List <DiscountType> discountAttaches, string callBackurl, FormGenerator.DataStructure.FormStructure formModel, List <BoothOfficer> boothOfficers) { Dictionary <UserBooth, string> shopUsers = new Dictionary <UserBooth, string>(); var modifyResult = new ModelView.ModifyResult <UserBooth>(); Booth booth = new BoothBO().Get(connectionHandler, userBooth.BoothId); string additionalData = new CongressDiscountTypeBO().FillTempAdditionalData(connectionHandler, booth.CongressId); if (booth.ValidCost.ToDecimal() > 0) { string payer = userBooth.EnterpriseNode.DescriptionField; Temp temp = new Temp { PayerId = userBooth.UserId, CallBackUrl = callBackurl, PayerTitle = payer, Description = Resources.Congress.PaymentBoothReserv + " " + booth.Code, Amount = new CongressDiscountTypeBO().CalulateAmountNew(paymentConnection, (booth.ValidCost.ToDecimal()), discountAttaches), CurrencyType = (byte)booth.CurrencyType.ToEnum <Radyn.Common.Definition.Enums.CurrencyType>(), AdditionalData = additionalData }; if ( !PaymentComponenets.Instance.TempTransactionalFacade(paymentConnection) .Insert(temp, discountAttaches)) { return(modifyResult); } userBooth.TempId = temp.Id; } else { if (userBooth.TempId.HasValue) { PaymentComponenets.Instance.TempTransactionalFacade(paymentConnection).Delete(userBooth.TempId); } userBooth.TempId = null; } if (userBooth.TempId == null) { userBooth.Status = (byte)Enums.RezervState.PayConfirm; } return(UserBoothInsert(connectionHandler, formGeneratorConnection, enterpriseNodeConnection, userBooth, formModel, boothOfficers)); }
public bool HotelUserUpdate(IConnectionHandler connectionHandler, IConnectionHandler formGeneratorConnection, HotelUser hotelUser, FormGenerator.DataStructure.FormStructure formModel) { FormGenerator.Facade.Interface.IFormDataFacade formDataTransactionalFacade = FormGeneratorComponent.Instance.FormDataTransactionalFacade(formGeneratorConnection); if (!Update(connectionHandler, hotelUser)) { throw new Exception(Resources.Congress.ErrorInSaveHotelReserv); } formModel.RefId = hotelUser.UserId + "," + hotelUser.HotelId; if (!formDataTransactionalFacade.ModifyFormData(formModel)) { throw new Exception(Resources.Congress.ErrorInSaveHotelReserv); } return(true); }
public KeyValuePair <bool, Guid> HotelUserInsert(IConnectionHandler connectionHandler, IConnectionHandler paymentConnection, IConnectionHandler formGeneratorConnection, Guid hotelId, User parentUser, List <DiscountType> discountAttaches, string callBackurl, FormGenerator.DataStructure.FormStructure formModel, int dayCount, List <Guid> userIdlist) { Guid? outvalue = null; Hotel hotel = new HotelBO().Get(connectionHandler, hotelId); int newlistCount = 0; List <Guid> validlist = new List <Guid>(); Payment.Facade.Interface.ITempFacade tempTransactionalFacade = PaymentComponenets.Instance.TempTransactionalFacade(paymentConnection); List <Guid> @select = Select(connectionHandler, x => x.UserId, x => x.HotelId == hotelId); CongressDiscountTypeBO congressDiscountTypeBo = new CongressDiscountTypeBO(); string additionalData = congressDiscountTypeBo.FillTempAdditionalData(connectionHandler, hotel.CongressId); foreach (Guid guid1 in userIdlist) { bool hotelUser = @select.Any(x => x == guid1); if (!hotelUser) { newlistCount++; validlist.Add(guid1); } else { validlist.Add(guid1); } } List <HotelUser> list = Where(connectionHandler, x => (x.UserId == parentUser.Id || x.User.ParentId == parentUser.Id) && x.HotelId == hotelId, true); foreach (HotelUser hotelUser in list) { if (validlist.Any(x => x.Equals(hotelUser.UserId))) { continue; } if (hotelUser.Status != (byte)Enums.RezervState.RegisterRequest && hotelUser.Status != (byte)Enums.RezervState.DenialPay) { continue; } if (hotelUser.TempId.HasValue) { tempTransactionalFacade.Delete(hotelUser.TempId); } if (!base.Delete(connectionHandler, hotelUser)) { throw new Exception(Resources.Congress.ErrorInSaveHotelReserv); } } if (hotel.FreeCapicity < newlistCount) { throw new Exception(Resources.Congress.HotelCapacityLessThanNumberOfSelectedUser); } if (hotel.ValidCost.ToDecimal() > 0 && validlist.Any()) { outvalue = SelectFirstOrDefault(connectionHandler, x => x.TempId, x => x.UserId.In(validlist) && x.HotelId == hotelId); decimal calulateAmountNew = congressDiscountTypeBo.CalulateAmountNew(paymentConnection, ((hotel.ValidCost.ToDecimal()) * dayCount) * validlist.Count, discountAttaches); if (outvalue == null) { outvalue = Guid.NewGuid(); Temp temp = new Temp { Id = (Guid)outvalue, PayerId = parentUser.Id, CallBackUrl = callBackurl + outvalue, Description = Resources.Congress.PaymentHotelReserv + " " + hotel.Name, PayerTitle = parentUser.DescriptionField, Amount = calulateAmountNew, CurrencyType = (byte)hotel.CurrencyType.ToEnum <Radyn.Common.Definition.Enums.CurrencyType>(), AdditionalData = additionalData }; if (!tempTransactionalFacade.Insert(temp, discountAttaches)) { return(new KeyValuePair <bool, Guid>(false, Guid.Empty)); } } else { Temp tr = tempTransactionalFacade.Get(outvalue); tr.Amount = calulateAmountNew; tr.CurrencyType = (byte)hotel.CurrencyType.ToEnum <Radyn.Common.Definition.Enums.CurrencyType>(); tr.AdditionalData = additionalData; if (!tempTransactionalFacade.Update(tr, discountAttaches)) { return(new KeyValuePair <bool, Guid>(false, Guid.Empty)); } } } FormGenerator.Facade.Interface.IFormDataFacade formDataTransactionalFacade = FormGeneratorComponent.Instance.FormDataTransactionalFacade(formGeneratorConnection); List <HotelUser> @selectd = Where(connectionHandler, x => x.HotelId == hotelId && x.UserId.In(validlist), true); foreach (Guid id in validlist) { HotelUser hotelUser = @selectd.FirstOrDefault(x => x.UserId == id); if (hotelUser == null) { HotelUser hotelUser1 = new HotelUser() { UserId = id, HotelId = hotelId, DaysCount = dayCount }; if (outvalue != null) { hotelUser1.TempId = outvalue; } else { hotelUser1.TempId = null; hotelUser1.Status = (byte)Enums.RezervState.PayConfirm; } if (!Insert(connectionHandler, hotelUser1)) { throw new Exception(Resources.Congress.ErrorInSaveHotelReserv); } } else { if (outvalue != null) { hotelUser.TempId = outvalue; } else { if (hotelUser.TempId.HasValue) { tempTransactionalFacade.Delete(hotelUser.TempId); } hotelUser.TempId = null; hotelUser.Status = (byte)Enums.RezervState.PayConfirm; } hotelUser.DaysCount = dayCount; if (!Update(connectionHandler, hotelUser)) { throw new Exception(Resources.Congress.ErrorInSaveHotelReserv); } } formModel.RefId = id + "," + hotelId; if (!formDataTransactionalFacade.ModifyFormData(formModel)) { throw new Exception(Resources.Congress.ErrorInSaveHotelReserv); } } return(new KeyValuePair <bool, Guid>(true, outvalue != null ? (Guid)outvalue : Guid.Empty)); }
public KeyValuePair <bool, Guid> HotelUserInsert(Guid congressId, Guid hotelId, User parentUser, List <DiscountType> discountAttaches, string callBackurl, FormGenerator.DataStructure.FormStructure formModel, int dayCount, List <Guid> userIdlist) { KeyValuePair <bool, Guid> keyValuePair; var entitiys = new ModelView.InFormEntitiyList <HotelUser>(); try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.PaymentConnection.StartTransaction(IsolationLevel.ReadUncommitted); this.FormGeneratorConnection.StartTransaction(IsolationLevel.ReadUncommitted); var hotelUserInsertGroup = new HotelUserBO().HotelUserInsert(this.ConnectionHandler, this.PaymentConnection, this.FormGeneratorConnection, hotelId, parentUser, discountAttaches, callBackurl, formModel, dayCount, userIdlist); if (hotelUserInsertGroup.Key && userIdlist.Count > 0) { entitiys.Add( new HotelUser() { HotelId = hotelId, UserId = parentUser.Id }, Resources.Congress.HotelInsertEmail, Resources.Congress.HotelInsertSMS ); } this.ConnectionHandler.CommitTransaction(); this.PaymentConnection.CommitTransaction(); this.FormGeneratorConnection.CommitTransaction(); keyValuePair = new KeyValuePair <bool, Guid>(hotelUserInsertGroup.Key, hotelUserInsertGroup.Value); } catch (KnownException ex) { this.ConnectionHandler.RollBack(); this.PaymentConnection.RollBack(); this.FormGeneratorConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { this.ConnectionHandler.RollBack(); this.PaymentConnection.RollBack(); this.FormGeneratorConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } try { if (keyValuePair.Key) { new HotelUserBO().InformHotelReserv(this.ConnectionHandler, congressId, entitiys); } } catch (Exception) { } return(keyValuePair); }
public KeyValuePair <bool, Guid> InsertGuest(EnterpriseNode.DataStructure.EnterpriseNode enterpriseNode, List <Guid> boothIdlist, HttpPostedFileBase file, List <DiscountType> discountAttaches, string callBackurl, FormGenerator.DataStructure.FormStructure postFormData, Guid congressId) { var keyValuePairs = new ModelView.InFormEntitiyList <UserBooth>(); var guid = Guid.Empty; var userBoothBo = new UserBoothBO(); try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.PaymentConnection.StartTransaction(IsolationLevel.ReadUncommitted); this.FormGeneratorConnection.StartTransaction(IsolationLevel.ReadUncommitted); this.EnterpriseNodeConnection.StartTransaction(IsolationLevel.ReadUncommitted); var additionalData = new CongressDiscountTypeBO().FillTempAdditionalData(this.ConnectionHandler, congressId); if ( !EnterpriseNodeComponent.Instance.EnterpriseNodeTransactionalFacade(this.EnterpriseNodeConnection) .Insert(enterpriseNode, file)) { return(new KeyValuePair <bool, Guid>(false, Guid.Empty)); } postFormData.RefId = enterpriseNode.Id.ToString(); if ( !FormGeneratorComponent.Instance.FormDataTransactionalFacade(this.FormGeneratorConnection) .ModifyFormData(postFormData)) { throw new Exception(Resources.Congress.ErrorInSaveBoothReserv); } var boothBo = new BoothBO(); var amount = boothBo.Sum(ConnectionHandler, x => x.ValidCost, x => x.Id.In(boothIdlist)); if (amount.ToDecimal() > 0) { var firstOrDefault = boothIdlist.FirstOrDefault(); var booth = boothBo.Get(this.ConnectionHandler, firstOrDefault); var temp = new Temp { PayerId = enterpriseNode.Id, CallBackUrl = callBackurl + enterpriseNode.Id, PayerTitle = enterpriseNode.DescriptionField, Description = Resources.Congress.PaymentBoothReserv, Amount = new CongressDiscountTypeBO().CalulateAmountNew(this.PaymentConnection, amount.ToDecimal(), discountAttaches), CurrencyType = (byte)booth.CurrencyType.ToEnum <Radyn.Common.Definition.Enums.CurrencyType>(), AdditionalData = additionalData }; if ( !PaymentComponenets.Instance.TempTransactionalFacade(this.PaymentConnection) .Insert(temp, discountAttaches)) { return(new KeyValuePair <bool, Guid>(false, Guid.Empty)); } guid = temp.Id; } foreach (var guid1 in boothIdlist) { var userBooth = new UserBooth() { UserId = enterpriseNode.Id, BoothId = guid1, TempId = guid != Guid.Empty ? guid : (Guid?)null, }; if (!userBoothBo.Insert(this.ConnectionHandler, userBooth)) { throw new Exception(Resources.Congress.ErrorInSaveBoothReserv); } keyValuePairs.Add(userBooth, Resources.Congress.BoothInsertEmail, Resources.Congress.BoothInsertSMS); } this.ConnectionHandler.CommitTransaction(); this.PaymentConnection.CommitTransaction(); this.FormGeneratorConnection.CommitTransaction(); this.EnterpriseNodeConnection.CommitTransaction(); } catch (KnownException ex) { this.ConnectionHandler.RollBack(); this.PaymentConnection.RollBack(); this.FormGeneratorConnection.RollBack(); this.EnterpriseNodeConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { this.ConnectionHandler.RollBack(); this.PaymentConnection.RollBack(); this.FormGeneratorConnection.RollBack(); this.EnterpriseNodeConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } try { userBoothBo.InformUserboothReserv(this.ConnectionHandler, congressId, keyValuePairs); } catch (Exception) { } return(new KeyValuePair <bool, Guid>(true, guid)); }