// GET: /ServicingOptionSelect public ActionResult SelectServicingOptionToOrder(int id) { //Get Group ServicingOptionGroup servicingOptionGroup = new ServicingOptionGroup(); servicingOptionGroup = servicingOptionGroupRepository.GetGroup(id); //Check Exists if (servicingOptionGroup == null) { ViewData["ActionMethod"] = "ListGet"; return(View("RecordDoesNotExistError")); } //Set Access Rights ViewData["Access"] = ""; RolesRepository rolesRepository = new RolesRepository(); if (rolesRepository.HasWriteAccessToServicingOptionGroup(id)) { ViewData["Access"] = "WriteAccess"; } ServicingOptionHFLFVM servicingOptionHFLFVM = new ServicingOptionHFLFVM(); ServicingOptionRepository servicingOptionRepository = new ServicingOptionRepository(); servicingOptionHFLFVM.ServicingOptionGroup = servicingOptionGroup; servicingOptionHFLFVM.ServicingOptions = new SelectList(servicingOptionRepository.GetServicingOptionsHFLFSelectList(id).ToList(), "ServicingOptionId", "ServicingOptionName"); return(View(servicingOptionHFLFVM)); }
public JsonResult GetServicingOptionGDSRequired(int servicingOptionId) { ServicingOptionRepository servicingOptionRepository = new ServicingOptionRepository(); ServicingOption servicingOption = new ServicingOption(); servicingOption = servicingOptionRepository.GetServicingOption(servicingOptionId); var result = (servicingOption != null && servicingOption.GDSRequiredFlag == true) ? true : false; return(Json(result)); }
// GET: /Edit public ActionResult Edit(int id) { ServicingOptionItem servicingOptionItem = new ServicingOptionItem(); servicingOptionItem = servicingOptionItemRepository.GetItem(id); //Check Exists if (servicingOptionItem == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } //AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToServicingOptionGroup(servicingOptionItem.ServicingOptionGroupId)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } ServicingOptionRepository servicingOptionRepository = new ServicingOptionRepository(); SelectList servicingOptionsList = new SelectList(servicingOptionRepository.GetAllServicingOptions().ToList(), "ServicingOptionId", "ServicingOptionName"); ViewData["ServicingOptions"] = servicingOptionsList; GDSRepository gdsRepository = new GDSRepository(); SelectList gDSList = new SelectList(gdsRepository.GetAllGDSsExceptALL().ToList(), "GDSCode", "GDSName"); ViewData["GDSs"] = gDSList; ViewData["DepartureTimeWindowMinutesList"] = new SelectList( servicingOptionRepository.GetServicingOptionDepartureTimeWindows().Select( x => new { value = x, text = x } ), "value", "text", servicingOptionItem.DepartureTimeWindowMinutes); ViewData["ArrivalTimeWindowMinutesList"] = new SelectList( servicingOptionRepository.GetServicingOptionArrivalTimeWindows().Select( x => new { value = x, text = x } ), "value", "text", servicingOptionItem.ArrivalTimeWindowMinutes); ViewData["MaximumStopsList"] = new SelectList( servicingOptionRepository.GetServicingOptionMaximumStops().Select( x => new { value = x, text = x } ), "value", "text", servicingOptionItem.MaximumStops); servicingOptionItemRepository.EditItemForDisplay(servicingOptionItem); return(View(servicingOptionItem)); }
public JsonResult GetServicingOptionParametersRequired(int servicingOptionId) { ServicingOptionRepository servicingOptionRepository = new ServicingOptionRepository(); ServicingOption servicingOption = new ServicingOption(); servicingOption = servicingOptionRepository.GetServicingOption(servicingOptionId); var result = (servicingOption != null && ( servicingOption.ServicingOptionId == 1 || servicingOption.ServicingOptionId == 2 || servicingOption.ServicingOptionId == 90 || servicingOption.ServicingOptionId == 291) ) ? true : false; return(Json(result)); }
// GET: /Create public ActionResult Create(int id) { //Check Exists ServicingOptionGroup servicingOptionGroup = new ServicingOptionGroup(); servicingOptionGroup = servicingOptionGroupRepository.GetGroup(id); if (servicingOptionGroup == null) { ViewData["ActionMethod"] = "CreateGet"; return(View("RecordDoesNotExistError")); } RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToServicingOptionGroup(id)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } ServicingOptionRepository servicingOptionRepository = new ServicingOptionRepository(); SelectList servicingOptionsList = new SelectList(servicingOptionRepository.GetAvailableServicingOptions(id).ToList(), "ServicingOptionId", "ServicingOptionName"); ViewData["ServicingOptions"] = servicingOptionsList; GDSRepository gdsRepository = new GDSRepository(); SelectList gDSList = new SelectList(gdsRepository.GetAllGDSsExceptALL().ToList(), "GDSCode", "GDSName"); ViewData["GDSs"] = gDSList; ViewData["DepartureTimeWindowMinutesList"] = new SelectList(servicingOptionRepository.GetServicingOptionDepartureTimeWindows().Select(x => new { value = x, text = x }), "value", "text"); ViewData["ArrivalTimeWindowMinutesList"] = new SelectList(servicingOptionRepository.GetServicingOptionArrivalTimeWindows().Select(x => new { value = x, text = x }), "value", "text"); ViewData["MaximumStopsList"] = new SelectList(servicingOptionRepository.GetServicingOptionMaximumStops().Select(x => new { value = x, text = x }), "value", "text"); ServicingOptionItem servicingOptionItem = new ServicingOptionItem(); servicingOptionItem.ServicingOptionGroupName = servicingOptionGroup.ServicingOptionGroupName; servicingOptionItem.ServicingOptionGroupId = servicingOptionGroup.ServicingOptionGroupId; return(View(servicingOptionItem)); }
// GET: /EditSequence public ActionResult EditSequence(int groupid, int id, int?page) { //Check Exists //Get Group ServicingOptionGroup servicingOptionGroup = new ServicingOptionGroup(); servicingOptionGroup = servicingOptionGroupRepository.GetGroup(groupid); //Check Exists if (servicingOptionGroup == null) { ViewData["ActionMethod"] = "ListGet"; return(View("RecordDoesNotExistError")); } //Check Access Rights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToServicingOptionGroup(groupid)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } ServicingOptionItemSequenceRepository servicingOptionItemSequenceRepository = new ServicingOptionItemSequenceRepository(); ServicingOptionRepository servicingOptionRepository = new ServicingOptionRepository(); ServicingOptionItemSequencesVM servicingOptionItemSequencesVM = new ServicingOptionItemSequencesVM(); servicingOptionItemSequencesVM.ServicingOptionItemSequences = servicingOptionItemSequenceRepository.GetServicingOptionItemSequences(groupid, id, page ?? 1); servicingOptionItemSequencesVM.ServicingOptionGroup = servicingOptionGroup; servicingOptionItemSequencesVM.ServicingOption = servicingOptionRepository.GetServicingOption(id); servicingOptionItemSequencesVM.ServicingOptionId = id; ViewData["Page"] = page ?? 1; return(View(servicingOptionItemSequencesVM)); }
public ActionResult EditSequence(int groupid, int page, int id, FormCollection collection) { //Check Exists ServicingOptionGroup servicingOptionGroup = new ServicingOptionGroup(); servicingOptionGroup = servicingOptionGroupRepository.GetGroup(groupid); if (servicingOptionGroup == null) { ViewData["ActionMethod"] = "EditSequencePost"; return(View("RecordDoesNotExistError")); } //Check Exists ServicingOption servicingOption = new ServicingOption(); ServicingOptionRepository servicingOptionRepository = new ServicingOptionRepository(); servicingOption = servicingOptionRepository.GetServicingOption(id); if (servicingOption == null) { ViewData["ActionMethod"] = "EditSequencePost"; return(View("RecordDoesNotExistError")); } //Check Access Rights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToServicingOptionGroup(groupid)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } string[] sequences = collection["Sequence"].Split(new char[] { ',' }); int sequence = (page - 1 * 5) - 2; if (sequence < 0) { sequence = 1; } XmlDocument doc = new XmlDocument();// Create the XML Declaration, and append it to XML document XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null); doc.AppendChild(dec); XmlElement root = doc.CreateElement("SequenceXML"); doc.AppendChild(root); foreach (string s in sequences) { string[] primaryKey = s.Split(new char[] { '_' }); int servicingOptionItemId = Convert.ToInt32(primaryKey[0]); int versionNumber = Convert.ToInt32(primaryKey[1]); XmlElement xmlItem = doc.CreateElement("Item"); root.AppendChild(xmlItem); XmlElement xmlSequence = doc.CreateElement("Sequence"); xmlSequence.InnerText = sequence.ToString(); xmlItem.AppendChild(xmlSequence); XmlElement xmlServicingOptionItemId = doc.CreateElement("ServicingOptionItemId"); xmlServicingOptionItemId.InnerText = servicingOptionItemId.ToString(); xmlItem.AppendChild(xmlServicingOptionItemId); XmlElement xmlVersionNumber = doc.CreateElement("VersionNumber"); xmlVersionNumber.InnerText = versionNumber.ToString(); xmlItem.AppendChild(xmlVersionNumber); sequence = sequence + 1; } try { ServicingOptionItemSequenceRepository servicingOptionItemSequenceRepository = new ServicingOptionItemSequenceRepository(); servicingOptionItemSequenceRepository.UpdateServicingOptionItemSequences(System.Xml.Linq.XElement.Parse(doc.OuterXml)); } catch (SqlException ex) { //Versioning Error if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/servicingOptionItem.mvc/EditSequence?page=" + page + "&id=" + id + "&groupid=" + groupid; return(View("VersionError")); } LogRepository logRepository = new LogRepository(); logRepository.LogError(ex.Message); ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details"; return(View("Error")); } return(RedirectToAction("List", new { id = groupid })); }