Пример #1
0
        public IEnumerable <ModelView.ReportChartModel> CharHotelCountWithReserv(IConnectionHandler connectionHandler, Guid congressId)
        {
            List <ModelView.ReportChartModel> listout = new List <ModelView.ReportChartModel>();
            List <dynamic> list = GroupBy(connectionHandler,
                                          new Expression <Func <HotelUser, object> >[] { x => x.Hotel.Address },
                                          new GroupByModel <HotelUser>[]
            {
                new GroupByModel <HotelUser>()
                {
                    Expression           = x => x.HotelId,
                    AggrigateFuntionType = AggrigateFuntionType.Count
                },
            }, x => x.Hotel.CongressId == congressId);
            List <dynamic> allType = new HotelBO().Select(connectionHandler, new Expression <Func <Hotel, object> >[]
            {
                x => x.Address,
            }, x => x.CongressId == congressId);

            foreach (dynamic item in allType)
            {
                dynamic first = list.FirstOrDefault(x => (x.Address is string) && (string)x.Address == (string)item.Address);
                listout.Add(new ModelView.ReportChartModel()
                {
                    Count = first?.CountHotelId ?? 0,
                    Value = (string)item.Address
                });
            }
            return(listout);
        }
Пример #2
0
        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));
        }