// GET: /Edit public ActionResult Edit(int id, int weekDayId, DateTime openingDateTime) { //AccessRights LocalOperatingHoursItem localOperatingHoursItem = new LocalOperatingHoursItem(); localOperatingHoursItem = localOperatingHoursRepository.GetItem(id, weekDayId, openingDateTime); if (localOperatingHoursItem == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToLocalOperatingHoursGroup(localOperatingHoursItem.LocalOperatingHoursGroupId)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } WeekdayRepository weekdayRepository = new WeekdayRepository(); SelectList weekdayList = new SelectList(weekdayRepository.GetAllWeekdays().ToList(), "WeekdayId", "WeekdayName"); ViewData["Weekdays"] = weekdayList; localOperatingHoursRepository.EditItemForDisplay(localOperatingHoursItem); return(View(localOperatingHoursItem)); }
// GET: /Create public ActionResult Create(int id) { LocalOperatingHoursGroup group = new LocalOperatingHoursGroup(); group = localOperatingHoursGroupRepository.GetGroup(id); //Check Exists if (group == null) { ViewData["ActionMethod"] = "CreateGet"; return(View("RecordDoesNotExistError")); } //Check AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToLocalOperatingHoursGroup(id)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } WeekdayRepository weekdayRepository = new WeekdayRepository(); SelectList weekdayList = new SelectList(weekdayRepository.GetAllWeekdays().ToList(), "WeekdayId", "WeekdayName"); ViewData["Weekdays"] = weekdayList; ViewData["hourList"] = new SelectList(new[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11" } .Select(x => new { value = x, text = x }), "value", "text", ""); LocalOperatingHoursItem localOperatingHoursItem = new LocalOperatingHoursItem(); localOperatingHoursItem.LocalOperatingHoursGroupName = group.LocalOperatingHoursGroupName; localOperatingHoursItem.LocalOperatingHoursGroupId = group.LocalOperatingHoursGroupId; return(View(localOperatingHoursItem)); }