Beispiel #1
0
        public ActionResult AddEditNewscast(AddEditNewscastViewModel viewModel)
        {
            viewModel.StartTime = viewModel.StartHour + ":" + viewModel.StartMinute + " " + viewModel.StartPeriod;
            //viewModel.EndTime = viewModel.EndHour + ":" + viewModel.EndMinute + " " + viewModel.EndPeriod;
            viewModel.HourlyInd = viewModel.HourlyInd != true && viewModel.HourlyInd != false ? viewModel.HourlyInd = false : viewModel.HourlyInd;
            // viewModel.DurationMinutes = viewModel.HourlyInd != true ? 0 : viewModel.DurationMinutes;

            if (ModelState.IsValid)
            {
                var scheduleNewscastId = CRCDataAccess.SaveScheduleNewscast(
                    viewModel.ScheduleNewscastId.HasValue ? viewModel.ScheduleNewscastId.Value : 0,
                    viewModel.ScheduleId,
                    viewModel.StartTime,
                    viewModel.EndTime,
                    viewModel.HourlyInd.ToIndicator(),
                    viewModel.DurationMinutes,
                    viewModel.SundayInd.ToIndicator(),
                    viewModel.MondayInd.ToIndicator(),
                    viewModel.TuesdayInd.ToIndicator(),
                    viewModel.WednesdayInd.ToIndicator(),
                    viewModel.ThursdayInd.ToIndicator(),
                    viewModel.FridayInd.ToIndicator(),
                    viewModel.SaturdayInd.ToIndicator(),
                    CRCUser.UserId);

                return(Json(scheduleNewscastId, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var validationErrors =
                    ModelState.Keys
                    .Where(key => ModelState[key].Errors.Count > 0)
                    .ToDictionary(
                        key => key,
                        key => ModelState[key].Errors.First().ErrorMessage);

                return(Json(validationErrors));
            }
        }
Beispiel #2
0
        public ActionResult DeleteNewscast(AddEditNewscastViewModel viewModel)
        {
            CRCDataAccess.DeleteScheduleNewscast(viewModel.ScheduleNewscastId.HasValue ? viewModel.ScheduleNewscastId.Value : 0, CRCUser.UserId);

            return(Json(true, JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
        public ActionResult AddEditNewscast()
        {
            var viewModel = new AddEditNewscastViewModel();

            return(PartialView(viewModel));
        }