예제 #1
0
        public string UpdateSeries(string si, string ai, string bi, string sc, string cd, string nod, string sr)
        {
            var seriesId = -1;

            try
            {
                seriesId = Convert.ToInt32(si);
            }
            catch { }

            var series = AddSeriesBookingsBLL.SeriesGetById(seriesId);

            var agencyId = -1;

            try
            {
                agencyId = Convert.ToInt32(ai);
            }
            catch { }

            var agency = AddSeriesBookingsBLL.AgencyGetById(agencyId);

            var bookerId = -1;

            try
            {
                bookerId = Convert.ToInt32(bi);
            }
            catch { }

            var booker = AddSeriesBookingsBLL.AgencyContactGetById(bookerId);

            var seriesCode = sc;

            int cutoffDate = -1;

            try
            {
                cutoffDate = Convert.ToInt32(cd);
            }
            catch { }


            var noOfDays = -1;

            try
            {
                noOfDays = Convert.ToInt32(nod);
            }
            catch { }

            var specialRequest = sr;

            series.CutoffDate     = cutoffDate;
            series.NoOfDays       = noOfDays;
            series.Booker         = booker;
            series.Agency         = agency;
            series.SpecialRequest = specialRequest;

            AddSeriesBookingsBLL.SeriesSaveOrUpdate(series);
            series.SeriesCode = String.IsNullOrEmpty(seriesCode) ? "OSS" + series.Id : seriesCode;
            AddSeriesBookingsBLL.SeriesSaveOrUpdate(series);

            var createdBy = "";

            try
            {
                createdBy = series.CreatedBy.FullName;
            }
            catch { }

            var createdDate = "";

            try
            {
                createdDate = series.CreatedDate.Value.ToString("dd/MM/yyyy HH:mm");
            }
            catch { }

            var seriesDTO = new SeriesDTO()
            {
                Id             = series.Id,
                SeriesCode     = series.SeriesCode,
                CutoffDate     = series.CutoffDate,
                NoOfDays       = series.NoOfDays.ToString(),
                NoOfDaysTrip   = series.NoOfDays == 2 ? "2 days 1 night" : "3 days 2 nights",
                CreatedBy      = createdBy,
                CreatedDate    = createdDate,
                SpecialRequest = specialRequest,
            };

            if (series.Booker != null)
            {
                seriesDTO.Booker = new SeriesDTO.BookerDTO()
                {
                    Id   = series.Booker.Id,
                    Name = series.Booker.Name,
                };
            }

            if (series.Agency != null)
            {
                seriesDTO.Agency = new SeriesDTO.AgencyDTO()
                {
                    Id   = series.Agency.Id,
                    Name = series.Agency.Name
                };
            }

            Dispose();
            return(JsonConvert.SerializeObject(seriesDTO));
        }