Example #1
0
        public ActionResult Create(ClientScheduleFormViewModel formSchedule)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    ClientSchedule newSchedule =
                        Mapper.Map <ClientScheduleFormViewModel, ClientSchedule>(formSchedule);

                    var playlist = formSchedule.MediaFileList.Where(f => f.IsSelected == true)
                                   .Select(f => new ClientScheduleMediaFilesList
                    {
                        MediaFileID = f.ID,
                        PlayTime    = f.PlayTime
                    })
                                   .ToList();

                    newSchedule.MediaPlaylist = playlist;
                    clientScheduleService.CreateClientSchedule(newSchedule);
                    clientScheduleService.SaveClientSchedule();
                }
                else
                {
                    return(View(formSchedule));
                }
                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ViewBag["error"] = ex.Message;
                return(View(formSchedule));
            }
        }
Example #2
0
        // GET: Schedules/Create/5
        public ActionResult Create(int cId)
        {
            var files = mediaStorageService.GetMediaFiles();

            var model = new ClientScheduleFormViewModel();

            //model.MediaFileList = (ICollection< MediaFileViewModel>) Mapper.Map<IEnumerable<MediaFile>,
            //    IEnumerable<MediaFileViewModel>>(files);

            model.MediaFileList = (List <MediaFileSelectViewModel>)
                                  Mapper.Map <IEnumerable <MediaFile>, IEnumerable <MediaFileSelectViewModel> >(files);

            //model.CampaignID = cId;
            //model.CampaignName = cName;

            var campaign = campaignService.GetCmpaignIncludeSchedules(cId);

            model.CampaignID     = cId;
            model.CampaignName   = campaign.Name;
            model.OtherSchedules = Mapper.Map <IEnumerable <ClientSchedule>, IEnumerable <ClientScheduleViewModel> >
                                       (campaign.Schedules).ToList();

            return(View(model));
        }