//Add Data From Linked Tables for Display
        public void EditItemForDisplay(TicketQueueItem ticketQueueItem)
        {
            TicketTypeRepository ticketTypeRepository = new TicketTypeRepository();
            TicketType           ticketType           = new TicketType();

            ticketType = ticketTypeRepository.GetTicketType(ticketQueueItem.TicketTypeId);
            if (ticketType != null)
            {
                ticketQueueItem.TicketTypeDescription = ticketType.TicketTypeDescription;
            }

            TicketQueueGroupRepository ticketQueueGroupRepository = new TicketQueueGroupRepository();
            TicketQueueGroup           ticketQueueGroup           = new TicketQueueGroup();

            ticketQueueGroup = ticketQueueGroupRepository.GetGroup(ticketQueueItem.TicketQueueGroupId);
            if (ticketQueueGroup != null)
            {
                ticketQueueItem.TicketQueueGroupName = ticketQueueGroup.TicketQueueGroupName;
            }

            GDSRepository gdsRepository = new GDSRepository();
            GDS           gds           = new GDS();

            gds = gdsRepository.GetGDS(ticketQueueItem.GDSCode);
            if (gds != null)
            {
                ticketQueueItem.GDSName = gds.GDSName;
            }
        }
        // GET: Linked ClientSubUnits
        public ActionResult LinkedClientSubUnits(int id)
        {
            //Get Group From Database
            TicketQueueGroup group = new TicketQueueGroup();

            group = ticketQueueGroupRepository.GetGroup(id);

            //Check Exists
            if (group == null)
            {
                ViewData["ActionMethod"] = "ClientSubUnitGet";
                return(View("RecordDoesNotExistError"));
            }

            TicketQueueGroupClientSubUnitCountriesVM ticketQueueGroupClientSubUnits = new TicketQueueGroupClientSubUnitCountriesVM();

            ticketQueueGroupClientSubUnits.TicketQueueGroupId   = id;
            ticketQueueGroupClientSubUnits.TicketQueueGroupName = group.TicketQueueGroupName;

            List <ClientSubUnitCountryVM> clientSubUnitsAvailable = new List <ClientSubUnitCountryVM>();

            clientSubUnitsAvailable = ticketQueueGroupRepository.GetLinkedClientSubUnits(id, false);
            ticketQueueGroupClientSubUnits.ClientSubUnitsAvailable = clientSubUnitsAvailable;

            List <ClientSubUnitCountryVM> clientSubUnitsUnAvailable = new List <ClientSubUnitCountryVM>();

            clientSubUnitsUnAvailable = ticketQueueGroupRepository.GetLinkedClientSubUnits(id, true);
            ticketQueueGroupClientSubUnits.ClientSubUnitsUnAvailable = clientSubUnitsUnAvailable;


            return(View(ticketQueueGroupClientSubUnits));
        }
        // GET: /UnDelete
        public ActionResult UnDelete(int id)
        {
            //Get Item From Database
            TicketQueueGroup group = new TicketQueueGroup();

            group = ticketQueueGroupRepository.GetGroup(id);

            //Check Exists
            if (group == null || group.DeletedFlag == false)
            {
                ViewData["ActionMethod"] = "UnDeleteGet";
                return(View("RecordDoesNotExistError"));
            }

            //Check Access Rights
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToTicketQueueGroup(id))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }
            //Add Linked Items and Display
            ticketQueueGroupRepository.EditGroupForDisplay(group);
            return(View(group));
        }
        // GET: /Edit
        public ActionResult Edit(int id)
        {
            //Get Item From Database
            TicketQueueGroup group = new TicketQueueGroup();

            group = ticketQueueGroupRepository.GetGroup(id);

            //Check Exists
            if (group == null)
            {
                ViewData["ActionMethod"] = "EditGet";
                return(View("RecordDoesNotExistError"));
            }
            //Check Access
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToTicketQueueGroup(id))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }
            TripTypeRepository tripTypeRepository = new TripTypeRepository();
            SelectList         tripTypesList      = new SelectList(tripTypeRepository.GetAllTripTypes().ToList(), "TripTypeId", "TripTypeDescription");

            ViewData["TripTypes"] = tripTypesList;

            TablesDomainHierarchyLevelRepository tablesDomainHierarchyLevelRepository = new TablesDomainHierarchyLevelRepository();
            SelectList hierarchyTypesList = new SelectList(tablesDomainHierarchyLevelRepository.GetDomainHierarchies(groupName).ToList(), "HierarchyLevelTableName", "HierarchyLevelTableName");

            ViewData["HierarchyTypes"] = hierarchyTypesList;

            ticketQueueGroupRepository.EditGroupForDisplay(group);
            return(View(group));
        }
        public ActionResult Create(TicketQueueItem ticketQueueItem)
        {
            //Get WorkFlowGroup
            TicketQueueGroup ticketQueueGroup = new TicketQueueGroup();

            ticketQueueGroup = ticketQueueGroupRepository.GetGroup(ticketQueueItem.TicketQueueGroupId);

            //Check Exists
            if (ticketQueueGroup == null)
            {
                ViewData["ActionMethod"] = "CreateGet";
                return(View("RecordDoesNotExistError"));
            }
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToTicketQueueGroup(ticketQueueItem.TicketQueueGroupId))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //Update  Model from Form
            try
            {
                UpdateModel(ticketQueueItem);
            }
            catch
            {
                string n = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        n += error.ErrorMessage;
                    }
                }
                ViewData["Message"] = "ValidationError : " + n;
                return(View("Error"));
            }



            //Database Update
            try
            {
                ticketQueueItemRepository.Add(ticketQueueItem);
            }
            catch (SqlException ex)
            {
                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 = ticketQueueItem.TicketQueueGroupId }));
        }
Esempio n. 6
0
        //Change the deleted status on an item
        public void UpdateGroupDeletedStatus(TicketQueueGroup group)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_UpdateTicketQueueGroupDeletedStatus_v1(
                group.TicketQueueGroupId,
                group.DeletedFlag,
                adminUserGuid,
                group.VersionNumber
                );
        }
        // GET: /List/
        public ActionResult List(int id, int?page, string sortField, int?sortOrder)
        {
            //Get WorkFlowGroup
            TicketQueueGroup ticketQueueGroup = new TicketQueueGroup();

            ticketQueueGroup = ticketQueueGroupRepository.GetGroup(id);

            //Check Exists
            if (ticketQueueGroup == null)
            {
                ViewData["ActionMethod"] = "ListGet";
                return(View("RecordDoesNotExistError"));
            }

            //Set Access Rights
            ViewData["Access"] = "";
            RolesRepository rolesRepository = new RolesRepository();

            if (rolesRepository.HasWriteAccessToTicketQueueGroup(id))
            {
                ViewData["Access"] = "WriteAccess";
            }

            if (sortField != "PseudoCityOrOfficeId")
            {
                sortField = "TicketQueueItemDescription";
            }

            ViewData["CurrentSortField"] = sortField;


            if (sortOrder == 1)
            {
                ViewData["NewSortOrder"]     = 0;
                ViewData["CurrentSortOrder"] = 1;
            }
            else
            {
                ViewData["NewSortOrder"]     = 1;
                ViewData["CurrentSortOrder"] = 0;
            }

            ViewData["TicketQueueGroupId"]   = ticketQueueGroup.TicketQueueGroupId;
            ViewData["TicketQueueGroupName"] = ticketQueueGroup.TicketQueueGroupName;

            var paginatedView = ticketQueueItemRepository.GetTicketQueueGroupTicketQueueItems(id, page ?? 1, sortField, sortOrder ?? 0);

            return(View(paginatedView));
        }
        // GET: /View
        public ActionResult View(int id)
        {
            TicketQueueGroup group = new TicketQueueGroup();

            group = ticketQueueGroupRepository.GetGroup(id);

            //Check Exists
            if (group == null)
            {
                ViewData["ActionMethod"] = "ViewGet";
                return(View("RecordDoesNotExistError"));
            }

            ticketQueueGroupRepository.EditGroupForDisplay(group);
            return(View(group));
        }
        public ActionResult UnDelete(int id, FormCollection collection)
        {
            //Get Item From Database
            TicketQueueGroup group = new TicketQueueGroup();

            group = ticketQueueGroupRepository.GetGroup(id);

            //Check Exists
            if (group == null || group.DeletedFlag == false)
            {
                ViewData["ActionMethod"] = "UnsDeletePost";
                return(View("RecordDoesNotExistError"));
            }
            //Check Access
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToTicketQueueGroup(id))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }
            //Delete Item
            try
            {
                group.VersionNumber = Int32.Parse(collection["VersionNumber"]);
                group.DeletedFlag   = false;
                ticketQueueGroupRepository.UpdateGroupDeletedStatus(group);
            }
            catch (SqlException ex)
            {
                //Versioning Error - go to standard versionError page
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/TicketQueueGroup.mvc/Delete/" + id.ToString();
                    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("ListDeleted"));
        }
        public ActionResult LinkedClientSubUnits(int ticketQueueGroupId, string ClientSubUnitGuid)
        {
            //Get Item From Database
            TicketQueueGroup group = new TicketQueueGroup();

            group = ticketQueueGroupRepository.GetGroup(ticketQueueGroupId);

            //Check Exists
            if (group == null)
            {
                ViewData["ActionMethod"] = "ClientSubUnitPost";
                return(View("RecordDoesNotExistError"));
            }
            //Check Access Rights
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToTicketQueueGroup(ticketQueueGroupId))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //Database Update
            try
            {
                ticketQueueGroupRepository.UpdateLinkedClientSubUnit(ticketQueueGroupId, ClientSubUnitGuid);
            }
            catch (SqlException ex)
            {
                //Versioning Error
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/TicketQueueGroup.mvc/ClientSubUnit/" + ticketQueueGroupId.ToString();
                    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("LinkedClientSubUnits", new { id = ticketQueueGroupId }));
        }
Esempio n. 11
0
        //Add Group
        public void Add(TicketQueueGroup group)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_InsertTicketQueueGroup_v1(
                group.TicketQueueGroupName,
                group.EnabledFlag,
                group.EnabledDate,
                group.ExpiryDate,
                group.InheritFromParentFlag,
                group.TripTypeId,
                group.HierarchyType,
                group.HierarchyCode,
                group.TravelerTypeGuid,
                group.ClientSubUnitGuid,
                group.SourceSystemCode,
                adminUserGuid

                );
        }
        // GET: /Create
        public ActionResult Create()
        {
            //Check Access Rights to Domain
            if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }
            TripTypeRepository tripTypeRepository = new TripTypeRepository();
            SelectList         tripTypesList      = new SelectList(tripTypeRepository.GetAllTripTypes().ToList(), "TripTypeId", "TripTypeDescription");

            ViewData["TripTypes"] = tripTypesList;

            TablesDomainHierarchyLevelRepository tablesDomainHierarchyLevelRepository = new TablesDomainHierarchyLevelRepository();
            SelectList hierarchyTypesList = new SelectList(tablesDomainHierarchyLevelRepository.GetDomainHierarchies(groupName).ToList(), "HierarchyLevelTableName", "HierarchyLevelTableName");

            ViewData["HierarchyTypes"] = hierarchyTypesList;

            TicketQueueGroup group = new TicketQueueGroup();

            return(View(group));
        }
        // GET: /Create
        public ActionResult Create(int Id)
        {
            //Get WorkFlowGroup
            TicketQueueGroup ticketQueueGroup = new TicketQueueGroup();

            ticketQueueGroup = ticketQueueGroupRepository.GetGroup(Id);

            //Check Exists
            if (ticketQueueGroup == null)
            {
                ViewData["ActionMethod"] = "CreateGet";
                return(View("RecordDoesNotExistError"));
            }
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToTicketQueueGroup(Id))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            TicketTypeRepository ticketTypeRepository = new TicketTypeRepository();
            SelectList           ticketTypeList       = new SelectList(ticketTypeRepository.GetAllTicketTypes().ToList(), "TicketTypeId", "TicketTypeDescription");

            ViewData["TicketTypes"] = ticketTypeList;

            GDSRepository gdsRepository = new GDSRepository();
            SelectList    gdsList       = new SelectList(gdsRepository.GetAllGDSs().ToList(), "GDSCode", "GDSName");

            ViewData["GDSs"] = gdsList;


            TicketQueueItem ticketQueueItem = new TicketQueueItem();

            ticketQueueItem.TicketQueueGroupId   = ticketQueueGroup.TicketQueueGroupId;
            ticketQueueItem.TicketQueueGroupName = ticketQueueGroup.TicketQueueGroupName;
            return(View(ticketQueueItem));
        }
Esempio n. 14
0
        //Add Data From Linked Tables for Display
        public void EditGroupForDisplay(TicketQueueGroup group)
        {
            TripTypeRepository tripTypeRepository = new TripTypeRepository();
            TripType           tripType           = new TripType();

            tripType = tripTypeRepository.GetTripType(group.TripTypeId);
            if (tripType != null)
            {
                group.TripType = tripType.TripTypeDescription;
            }

            group.TicketQueueGroupName = Regex.Replace(group.TicketQueueGroupName, @"[^\w\-()*]", "-");

            //Hierarchy
            HierarchyRepository hierarchyRepository = new HierarchyRepository();

            List <fnDesktopDataAdmin_SelectTicketQueueGroupHierarchy_v1Result> hierarchy = GetGroupHierarchy(group.TicketQueueGroupId);

            if (hierarchy.Count > 0)
            {
                if (hierarchy.Count == 1)
                {
                    HierarchyGroup hierarchyGroup = hierarchyRepository.GetHierarchyGroup(
                        hierarchy[0].HierarchyType ?? "",
                        hierarchy[0].HierarchyCode ?? "",
                        hierarchy[0].HierarchyName ?? "",
                        hierarchy[0].TravelerTypeGuid ?? "",
                        hierarchy[0].TravelerTypeName ?? "",
                        hierarchy[0].SourceSystemCode ?? ""
                        );

                    if (hierarchyGroup != null)
                    {
                        group.HierarchyType     = hierarchyGroup.HierarchyType;
                        group.HierarchyCode     = hierarchyGroup.HierarchyCode;
                        group.HierarchyItem     = hierarchyGroup.HierarchyItem;
                        group.ClientSubUnitGuid = hierarchyGroup.ClientSubUnitGuid;
                        group.ClientSubUnitName = hierarchyGroup.ClientSubUnitName;
                        group.TravelerTypeGuid  = hierarchyGroup.TravelerTypeGuid;
                        group.TravelerTypeName  = hierarchyGroup.TravelerTypeName;
                        group.ClientTopUnitName = hierarchyGroup.ClientTopUnitName;
                        group.SourceSystemCode  = hierarchyGroup.SourceSystemCode;
                    }
                }
                else
                {
                    List <MultipleHierarchyDefinition> multipleHierarchies = new List <MultipleHierarchyDefinition>();
                    foreach (fnDesktopDataAdmin_SelectTicketQueueGroupHierarchy_v1Result item in hierarchy)
                    {
                        multipleHierarchies.Add(new MultipleHierarchyDefinition()
                        {
                            HierarchyType    = item.HierarchyType,
                            HierarchyItem    = item.HierarchyName,
                            HierarchyCode    = item.HierarchyCode,
                            TravelerTypeGuid = item.TravelerTypeGuid,
                            SourceSystemCode = item.SourceSystemCode
                        });
                    }
                    group.ClientSubUnitsHierarchy = hierarchyRepository.GetClientSubUnitHierarchies(multipleHierarchies);

                    ClientSubUnitRepository clientSubUnitRepository = new ClientSubUnitRepository();
                    group.ClientTopUnitName = clientSubUnitRepository.GetClientSubUnitClientTopUnitName(group.ClientSubUnitsHierarchy.First().ClientSubUnitGuid);
                }
            }

            if (hierarchy.Count > 1)
            {
                group.IsMultipleHierarchy = true;
                group.HierarchyType       = "Multiple";
                group.HierarchyItem       = "Multiple";
                group.HierarchyCode       = "Multiple";
            }
            else
            {
                group.IsMultipleHierarchy = false;
            }
        }
        public ActionResult Edit(int id, FormCollection collection)
        {
            //Get Item
            TicketQueueGroup group = new TicketQueueGroup();

            group = ticketQueueGroupRepository.GetGroup(id);

            //Check Exists
            if (group == null)
            {
                ViewData["ActionMethod"] = "DeletePost";
                return(View("RecordDoesNotExistError"));
            }

            //Check Access
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToTicketQueueGroup(id))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }
            try
            {
                UpdateModel(group);
            }
            catch
            {
                string n = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        n += error.ErrorMessage;
                    }
                }
                ViewData["Message"] = "ValidationError : " + n;
                return(View("Error"));
            }

            //Dont check for multiple as We are not editing Hierarchy, we have alrady checked access to the item itself
            if (group.HierarchyType != "Multiple")
            {
                //ClientSubUnitTravelerType has extra field
                string hierarchyCode = group.HierarchyCode;
                if (group.HierarchyType == "ClientSubUnitTravelerType")
                {
                    group.ClientSubUnitGuid = hierarchyCode;  //ClientSubUnitTravelerType has 2 primarykeys
                }

                //Check Access Rights to PolicyGroup
                HierarchyRepository hierarchyRepository = new HierarchyRepository();
                if (!hierarchyRepository.AdminHasDomainHierarchyWriteAccess(group.HierarchyType, hierarchyCode, group.SourceSystemCode, groupName))
                {
                    ViewData["Message"] = "You cannot add to this hierarchy item";
                    return(View("Error"));
                }
            }

            //Database Update
            try
            {
                ticketQueueGroupRepository.Edit(group);
            }
            catch (SqlException ex)
            {
                //Versioning Error
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/TicketQueueGroup.mvc/Edit/" + group.TicketQueueGroupId.ToString();
                    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("ListUnDeleted"));
        }
        public ActionResult Create(TicketQueueGroup group)
        {
            //Check Access Rights to Domain
            if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }
            //Check Access Rights to Domain Hierarchy
            if (!hierarchyRepository.AdminHasDomainHierarchyWriteAccess(group.HierarchyType, group.HierarchyCode, group.SourceSystemCode, groupName))
            {
                ViewData["Message"] = "You cannot add to this hierarchy item";
                return(View("Error"));
            }

            //Update Model From Form + Validate against DB
            try
            {
                UpdateModel(group);
            }
            catch
            {
                string n = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        n += error.ErrorMessage;
                    }
                }
                ViewData["Message"] = "ValidationError : " + n;
                return(View("Error"));
            }

            //ClientSubUnitTravelerType has extra field
            string hierarchyCode = group.HierarchyCode;

            if (group.HierarchyType == "ClientSubUnitTravelerType")
            {
                group.ClientSubUnitGuid = hierarchyCode;  //ClientSubUnitTravelerType has 2 primarykeys
            }

            //Database Update
            try
            {
                ticketQueueGroupRepository.Add(group);
            }
            catch (SqlException ex)
            {
                //Non-Unique Name
                if (ex.Message == "NonUniqueName")
                {
                    return(View("NonUniqueNameError"));
                }
                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"));
            }
            ViewData["NewSortOrder"] = 0;
            return(RedirectToAction("ListUnDeleted"));
        }