public ActionResult Edit(EditViewModel editViewModel)
        {
            if (editViewModel == null)
            {
                throw new HttpException(400, "Bad Request");
            }

            var voucherBatch = VoucherBatchService.FindById(editViewModel.VoucherBatchId);
            if (voucherBatch == null)
            {
                throw new HttpException(404, "Not Found");
            }

            var selectedTrip = TripService.FindById(editViewModel.DropDownList_Trip_Property.SelectedTrip);
            var selectedCruise = CruiseService.FindById(editViewModel.DropDownList_Cruise_Property.SelectedCruise);
            var selectedVoucherTemplate = VoucherTemplateService.FindById(editViewModel.DropDownList_VoucherTemplate_Property.SelectedVoucherTemplate);

            voucherBatch.Name = editViewModel.Name;
            voucherBatch.Description = editViewModel.Description;
            if (!String.IsNullOrEmpty(editViewModel.ValidUntil))
            {
                voucherBatch.ValidUntil = DateTime.ParseExact(editViewModel.ValidUntil, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            else
            {
                voucherBatch.IssueDate = null;
            }
            if (!String.IsNullOrEmpty(editViewModel.IssueDate))
            {
                voucherBatch.IssueDate = DateTime.ParseExact(editViewModel.IssueDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            else
            {
                voucherBatch.IssueDate = null;
            }
            voucherBatch.Value = editViewModel.Value;
            voucherBatch.Note = editViewModel.Note;
            voucherBatch.Trip = selectedTrip;
            voucherBatch.Cruise = selectedCruise;
            voucherBatch.VoucherTemplate = selectedVoucherTemplate;

            if (voucherBatch.Trip != null)
            {
                voucherBatch.TripId = selectedTrip.TripId;
            }
            else
            {
                voucherBatch.TripId = null;
            }

            if (voucherBatch.Cruise != null)
            {
                voucherBatch.CruiseId = selectedCruise.CruiseId;
            }
            else
            {
                voucherBatch.CruiseId = null;
            }

            if (voucherBatch.VoucherTemplate != null)
            {
                voucherBatch.VoucherTemplateId = selectedVoucherTemplate.VoucherTemplateId;
            }
            else
            {
                voucherBatch.VoucherTemplateId = null;
            }

            VoucherBatchService.UpdateVoucherBatch(voucherBatch);
            TempData["VoucherBatchId"] = voucherBatch.VoucherTemplateId;
            TempData["VoucherBatchName"] = voucherBatch.Name;
            TempData["Message"] = VoucherBatchesMessage.EditSuccess;
            return RedirectToAction("index", "voucherbatches");
        }
        public ActionResult Edit(int? id)
        {
            if (id == null)
            {
                throw new HttpException(400, "Bad Request");
            }

            var voucherBatch = VoucherBatchService.FindById(id.Value);
            if (voucherBatch == null)
            {
                throw new HttpException(404, "Not Found");
            }

            var voucherCodes = VoucherCodeService.GetVoucherCodes().Where(vc => vc.VoucherBatch.VoucherBatchId == voucherBatch.VoucherBatchId).ToList();

            var dropdownlist_Cruise_Property = new EditViewModel.DropDownList_Cruise()
            {
                Cruises = CruiseService.GetCruises().ToList(),
                SelectedCruise = voucherBatch.Cruise != null ? voucherBatch.Cruise.CruiseId : -1
            };

            var dropdownlist_Trip_Property = new EditViewModel.DropDownList_Trip()
            {
                Trips = TripService.GetTrips().ToList(),
                SelectedTrip = voucherBatch.Trip != null ? voucherBatch.Trip.TripId : -1
            };

            var dropdownlist_VoucherTemplate_Property = new EditViewModel.DropDownList_VoucherTemplate()
            {
                VoucherTemplates = VoucherTemplateService.GetVoucherTemplates().ToList(),
                SelectedVoucherTemplate = voucherBatch.VoucherTemplate != null ? voucherBatch.VoucherTemplate.VoucherTemplateId : -1
            };

            var voucherCodesString = new StringBuilder();
            for (int i = 0; i < voucherCodes.Count(); i++)
            {
                voucherCodesString.Append(voucherCodes[i].VoucherCodeString + ", ");
            }

            var editViewModel = new EditViewModel()
            {
                VoucherBatchId = voucherBatch.VoucherBatchId,
                Name = voucherBatch.Name,
                Description = voucherBatch.Description,
                IssueDate = voucherBatch.IssueDate != null ? voucherBatch.IssueDate.Value.ToString("dd/MM/yyyy") : "",
                ValidUntil = voucherBatch.ValidUntil != null ? voucherBatch.ValidUntil.Value.ToString("dd/MM/yyyy") : "",
                Quantity = voucherCodes.Count(),
                Note = voucherBatch.Note,
                Value = voucherBatch.Value,
                DropDownList_Cruise_Property = dropdownlist_Cruise_Property,
                DropDownList_Trip_Property = dropdownlist_Trip_Property,
                DropDownList_VoucherTemplate_Property = dropdownlist_VoucherTemplate_Property,
                VoucherCodes = voucherCodesString.ToString()
            };
            return View(editViewModel);
        }