Esempio n. 1
0
        public static void CreateCase()
        {
            var context = new IPTV2Entities();
            var gomsService = new GomsTfcTv();

            // var email = "*****@*****.**";
            var email = "*****@*****.**";
            var user = context.Users.FirstOrDefault(u => u.EMail == email);
            var agent = (GomsCaseAgent)context.GomsReferences.FirstOrDefault(r => r is GomsCaseAgent);
            var caseIssueType = (GomsCaseIssueType)context.GomsReferences.FirstOrDefault(r => r is GomsCaseIssueType);
            var caseSubIssueType = (GomsCaseSubIssueType)context.GomsReferences.FirstOrDefault(r => r is GomsCaseSubIssueType);
            var resp = gomsService.CreateSupportCase(context, user.UserId, "test case", "hope this works, please help...", agent, caseIssueType, caseSubIssueType);


        }
        private ErrorResponse CreateGomsTicket(string subject, string message)
        {
            ErrorResponse response;
            if (!MyUtility.isUserLoggedIn())
                return new ErrorResponse() { Code = (int)ErrorCodes.NotAuthenticated, Message = "User is not logged in." };

            var context = new IPTV2Entities();

            var user = context.Users.FirstOrDefault(u => u.UserId == new System.Guid(HttpContext.User.Identity.Name));
            if (user != null)
            {
                var gomsService = new GomsTfcTv();
                var agent = (GomsCaseAgent)context.GomsReferences.FirstOrDefault(r => r is GomsCaseAgent);
                var caseIssueType = (GomsCaseIssueType)context.GomsReferences.FirstOrDefault(r => r is GomsCaseIssueType);
                var caseSubIssueType = (GomsCaseSubIssueType)context.GomsReferences.FirstOrDefault(r => r is GomsCaseSubIssueType);
                try
                {
                    var resp = gomsService.CreateSupportCase(context, user.UserId, subject, message, agent, caseIssueType, caseSubIssueType);
                    response = new ErrorResponse() { Code = Convert.ToInt32(resp.StatusCode), Message = resp.StatusMessage };
                    response.Message = response.Code == 0 ? "You have successfully submitted a ticket." : resp.StatusMessage;
                }
                catch (Exception e)
                {
                    response = new ErrorResponse() { Code = (int)ErrorCodes.UnknownError, Message = e.Message };
                }
            }
            else
                response = new ErrorResponse() { Code = (int)ErrorCodes.UserDoesNotExist, Message = "User does not exist." };
            return response;
        }