예제 #1
0
        //get all albums and their average rate
        //get top 10
        //koristi se
        public List <RateDetails> GetAlbumRates()
        {
            List <AverageRate> list = _context.UsersAlbumRates
                                      .Join(_context.Album,
                                            rate => rate.AlbumId,
                                            album => album.Id,
                                            (rate, album) => new
            {
                album.Name,
                rate.Rate,
                rate.AlbumId,
                album.Image
            })
                                      .GroupBy(p => p.AlbumId)
                                      .Select(g => new AverageRate {
                Id = g.First().AlbumId, Title = g.First().Name, AvgRate = Math.Round(Convert.ToDouble(g.Sum(x => x.Rate)) / g.Count(), 1)
            }).OrderByDescending(x => x.AvgRate).Take(10).ToList();

            List <RateDetails> avgRateDetailList = new List <RateDetails>();

            foreach (AverageRate item in list)
            {
                Album       obj     = _context.Album.Include(x => x.Performer).Where(x => x.Id == item.Id).FirstOrDefault();
                RateDetails rateDet = new RateDetails()
                {
                    Id        = obj.Id,
                    Image     = obj.Image,
                    Title     = obj.Name,
                    Performer = obj.Performer.ArtisticName,
                    AvgRate   = item.AvgRate
                };
                avgRateDetailList.Add(rateDet);
            }
            return(avgRateDetailList);
        }
예제 #2
0
 private void ExecuteUndo(object obj)
 {
     Rate = new RateMaster();
     Rate.Rates.CollectionChanged += Rates_CollectionChanged;
     OnPropertyChanged("VTypeEnabled");
     RateDetails = new RateDetails();
     RateDetails.PropertyChanged += RateDetails_PropertyChanged;
     // LoadVehicleTypeList();
     SetAction(ButtonAction.Init);
 }
예제 #3
0
 void SetDefault()
 {
     //
     RateDetails.Rate    = 0;
     RateDetails.IsFixed = false;
     Rate.OnPropertyChanged("Rates");
     RateDetails.Mode   = 0;
     SelectedRateDetail = null;
     RateDetails.OnPropertyChanged("VehicleType");
     OnPropertyChanged("VTypeEnabled");
 }
 private InternalSlimRateDetails Convert(RateDetails rateDetails)
 => new InternalSlimRateDetails
 (
     rateDetails.Room.Id,
     rateDetails.Room.AccommodationId,
     rateDetails.PaymentDetails.TotalAmount,
     rateDetails.PaymentDetails.Discount.Percent,
     rateDetails.BoardBasis,
     rateDetails.CancellationPolicies.Select(cp => new InternalSlimCancellationPolicies
                                             (
                                                 cp.FromDate,
                                                 cp.ToDate,
                                                 cp.PenaltyAmount,
                                                 cp.Percent
                                             )).ToList(),
     rateDetails.RoomType,
     rateDetails.OccupationRequest
 );
예제 #5
0
 public RateViewModel()
 {
     MessageBoxCaption = "Rate Setup";
     Rate = new RateMaster();
     Rate.Rates.CollectionChanged += Rates_CollectionChanged;
     RateDetails = new RateDetails();
     RateDetails.PropertyChanged += RateDetails_PropertyChanged;
     LoadData           = new RelayCommand(ExecuteLoad);
     NewCommand         = new RelayCommand(ExecuteNew);
     EditCommand        = new RelayCommand(ExecuteEdit);
     DeleteCommand      = new RelayCommand(ExecuteDelete);
     SaveCommand        = new RelayCommand(ExecuteSave);
     UndoCommand        = new RelayCommand(ExecuteUndo);
     AddRateDetail      = new RelayCommand(ExecuteAdd, CanExecuteAdd);
     EditShiftCommand   = new RelayCommand(ExecuteModify, CanExecuteModify);
     RemoveShiftCommand = new RelayCommand(ExecuteRemove);
     VehicleTypeList    = new ObservableCollection <VehicleType>();
     LoadVehicleTypeList();
     SetAction(ButtonAction.Init);
 }
예제 #6
0
 private void ExecuteModify(object obj)
 {
     if (VTypeEnabled)
     {
         foreach (Day d in Days)
         {
             d.IsChecked = false;
         }
     }
     SelectedRateDetail = obj as RateDetails;
     RateDetails        = new RateDetails
     {
         Rate_ID     = SelectedRateDetail.Rate_ID,
         BeginTime   = SelectedRateDetail.BeginTime,
         EndTime     = SelectedRateDetail.EndTime,
         Rate        = SelectedRateDetail.Rate,
         Mode        = 1,
         IsFixed     = SelectedRateDetail.IsFixed,
         VehicleType = SelectedRateDetail.VehicleType
     };
     RateDetails.PropertyChanged += RateDetails_PropertyChanged;
     Days.First(x => x.DayId == SelectedRateDetail.Day).IsChecked = true;
     OnPropertyChanged("VTypeEnabled");
 }
예제 #7
0
        //get all songs and their average rate
        //get top 10
        //koristi se
        public List <RateDetails> GetSongRates()
        {
            //get average rate
            List <AverageRate> list = _context.UsersSongRates
                                      .Join(
                _context.Song,
                rate => rate.SongId,
                song => song.Id,
                (rate, song) => new
            {
                song.Title,
                rate.Rate,
                rate.SongId,
            })
                                      .GroupBy(p => p.SongId)
                                      .Select(g => new AverageRate {
                Id = g.First().SongId, Title = g.First().Title, AvgRate = Math.Round(Convert.ToDouble(g.Sum(x => x.Rate)) / g.Count(), 1)
            }).OrderByDescending(x => x.AvgRate).Take(10).ToList();

            List <RateDetails> avgRateDetailList = new List <RateDetails>();

            foreach (AverageRate item in list)
            {
                SongGetRequest obj     = _mapper.Map <SongGetRequest>(_context.Song.Include(x => x.Album).Include(x => x.Album.Performer).Where(x => x.Id == item.Id).FirstOrDefault());
                RateDetails    rateDet = new RateDetails()
                {
                    Id        = obj.Id,
                    Image     = obj.Album.Image,
                    Title     = obj.Title,
                    Performer = obj.Album.Performer.ArtisticName,
                    AvgRate   = item.AvgRate
                };
                avgRateDetailList.Add(rateDet);
            }
            return(avgRateDetailList);
        }
예제 #8
0
        public string UpdateRateDetais(int RateSNo, string Action, RateDetails RateInfo, List <RateRemarks> RateRemarks, List <RateAirlineSLAB> RateSLABInfoarray, List <RateULDAirlineSLAB> RateULDSLABInfoArray, RateParam RateParamList, string ErrorMSG)
        {
            string Result = "";

            try
            {
                //return null;
                List <RateDetails> lstRateDetails = new List <RateDetails>();
                lstRateDetails.Add(RateInfo);

                List <RateParam> lstRateParam = new List <RateParam>();
                lstRateParam.Add(RateParamList);

                DataTable dtRateDetails = CollectionHelper.ConvertTo(lstRateDetails, "");
                DataTable dtRateRemarks = CollectionHelper.ConvertTo(RateRemarks, "");
                DataTable dtRateSlab    = CollectionHelper.ConvertTo(RateSLABInfoarray, "HdnRateClassSNo");
                DataTable dtRateULDSlab = CollectionHelper.ConvertTo(RateULDSLABInfoArray, "HdnRateClassSNo,HdnULDSNo,HdnRateClassCode,Text_RateClassCode,RateClassCode");
                DataTable dtRateParam   = CollectionHelper.ConvertTo(lstRateParam, "");

                BaseBusiness baseBusiness     = new BaseBusiness();
                SqlParameter paramRateDetails = new SqlParameter();
                paramRateDetails.ParameterName = "@RateDetails";
                paramRateDetails.SqlDbType     = System.Data.SqlDbType.Structured;
                paramRateDetails.Value         = dtRateDetails;

                SqlParameter paramRateRemarks = new SqlParameter();
                paramRateRemarks.ParameterName = "@RateRemarks";
                paramRateRemarks.SqlDbType     = System.Data.SqlDbType.Structured;
                paramRateRemarks.Value         = dtRateRemarks;

                SqlParameter paramRateSlab = new SqlParameter();
                paramRateSlab.ParameterName = "@RateSLAB";
                paramRateSlab.SqlDbType     = System.Data.SqlDbType.Structured;
                paramRateSlab.Value         = dtRateSlab;

                SqlParameter paramRateULDSlab = new SqlParameter();
                paramRateULDSlab.ParameterName = "@RateULDSLAB";
                paramRateULDSlab.SqlDbType     = System.Data.SqlDbType.Structured;
                paramRateULDSlab.Value         = dtRateULDSlab;

                SqlParameter paramRateParam = new SqlParameter();
                paramRateParam.ParameterName = "@RateParam";
                paramRateParam.SqlDbType     = System.Data.SqlDbType.Structured;
                paramRateParam.Value         = dtRateParam;

                DataSet        ds         = new DataSet();
                SqlParameter[] Parameters =
                {
                    new SqlParameter("@RateSNo",       RateSNo),
                    new SqlParameter("@PerformAction", Action),
                    paramRateDetails,
                    paramRateRemarks,
                    paramRateSlab,
                    paramRateULDSlab,
                    paramRateParam,
                    new SqlParameter("@CreatedBy",     ((CargoFlash.Cargo.Model.UserLogin)(System.Web.HttpContext.Current.Session["UserDetail"])).UserSNo.ToString()),
                    new SqlParameter("@UpdatedBy",     ((CargoFlash.Cargo.Model.UserLogin)(System.Web.HttpContext.Current.Session["UserDetail"])).UserSNo.ToString()),
                    new SqlParameter("@ErrorMSg",      ErrorMSG),
                };

                ds = SqlHelper.ExecuteDataset(DMLConnectionString.WebConfigConnectionString, "spRate_UpdateDetails", Parameters);
                return(CargoFlash.Cargo.Business.Common.CompleteDStoJSON(ds));
                // return ds.Tables[ds.Tables.Count - 1].Rows[0][0].ToString();
            }
            catch (Exception ex)//
            {
                throw ex;
            }
            return(Result);
        }