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 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)); }