Ejemplo n.º 1
0
        public ActionResult AddEditProgram(long?programId)
        {
            var viewModel = new AddEditProgramViewModel();

            if (programId.HasValue)
            {
                var drProgram = CRCDataAccess.GetProgram(programId.Value);
                drProgram.MapTo(viewModel);

                viewModel.EnabledInd = !(drProgram["DisabledDate"] is DateTime);
            }

            return(View(viewModel));
        }
Ejemplo n.º 2
0
        public ActionResult AddEditProgram(AddEditProgramViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                CRCDataAccess.SaveProgram(
                    viewModel.ProgramId,
                    viewModel.ProgramName,
                    viewModel.ProgramSourceId,
                    viewModel.ProgramFormatTypeId,
                    viewModel.ProgramCode,
                    viewModel.CarriageTypeId,
                    viewModel.EnabledInd ? (DateTime?)null : DateTime.UtcNow,
                    viewModel.EnabledInd ? (long?)null : CRCUser.UserId,
                    CRCUser.UserId);

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(viewModel));
            }
        }
Ejemplo n.º 3
0
        public ActionResult AddEditProgram(AddEditProgramViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                // Workaround for end time being 12:00 am
                viewModel.EndTime = viewModel.EndTime == "12:00 am" ? "23:59:59" : viewModel.EndTime;

                var scheduleProgramId = CRCDataAccess.SaveScheduleProgram(
                    viewModel.ScheduleProgramId.HasValue ? viewModel.ScheduleProgramId.Value : 0,
                    viewModel.ScheduleId,
                    viewModel.ProgramSearch.ProgramId,
                    viewModel.StartTime,
                    viewModel.EndTime,
                    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(scheduleProgramId, 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));
            }
        }
Ejemplo n.º 4
0
        public ActionResult AddEditProgram(long incrMins)
        {
            var viewModel = new AddEditProgramViewModel(incrMins);

            return(PartialView(viewModel));
        }