Example #1
0
        public string SeriesGetStatus(int seriesId)
        {
            var series = SeriesManagerBLL.SeriesGetById(seriesId);
            var result = "";
            var listBookingGroupByStatus = series.ListBooking.GroupBy(x => x.Status);

            foreach (var bookingGroupByStatus in listBookingGroupByStatus)
            {
                result = result + bookingGroupByStatus.Count() + " " + bookingGroupByStatus.Key.ToString() + "</br>";
            }
            return(result);
        }
Example #2
0
        protected void rptListSeries_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var seriesId = Int32.Parse(e.CommandArgument.ToString());
            var series   = SeriesManagerBLL.SeriesGetById(seriesId);
            var haveCancelAllSeriesPermission = PermissionBLL.UserCheckPermission(UserBLL.UserGetCurrent().Id, (int)PermissionEnum.CANCELALLSERIES);

            if (e.CommandName == "cancel")
            {
                if (!haveCancelAllSeriesPermission)
                {
                    if (series.Agency.Sale.Id != UserBLL.UserGetCurrent().Id)
                    {
                        ShowError("Không được phép xóa series do người khác quản lý. Liên hệ manager để được cấp quyền ");
                        return;
                    }
                }

                var numberOfBookingApproved      = series.ListBooking.Where(x => x.Status == Util.StatusType.Approved).Count();
                var didSeriesHaveBookingApproved = false;
                if (numberOfBookingApproved > 0)
                {
                    didSeriesHaveBookingApproved = true;
                }

                var listMustCancel = new List <Booking>();
                foreach (var booking in series.ListBooking)
                {
                    if (booking.StartDate <= DateTime.Now.Date)
                    {
                        continue;
                    }
                    if (didSeriesHaveBookingApproved)
                    {
                        if (booking.Status == Util.StatusType.Pending)
                        {
                            listMustCancel.Add(booking);
                        }
                    }
                    else
                    {
                        listMustCancel.Add(booking);
                    }
                }

                foreach (var booking in listMustCancel)
                {
                    booking.Status       = Util.StatusType.Cancelled;
                    booking.ModifiedBy   = UserBLL.UserGetCurrent();
                    booking.ModifiedDate = DateTime.Now;
                    SeriesManagerBLL.BookingSaveOrUpdate(booking);
                    BookingHistorySave(booking);
                }
                ShowSuccess("Đã cancel tất cả booking pending trong series <strong>" + series.SeriesCode + "</strong>");

                if (listMustCancel.Count() > 0)
                {
                    SendEmailCancelSeries(listMustCancel, series);
                }
            }

            Reload();
        }