示例#1
0
        public HttpResponseMessage Hotel(IncomingBoundingBoxLocation location)
        {
            return(ErrorFactory.Handle(() =>
            {
                var currentUserId = User?.Identity?.GetUserId();

                if (string.IsNullOrWhiteSpace(currentUserId))
                {
                    throw new UnauthorizedAccessException();
                }

                using (var unitOfWork = new UnitOfWork())
                {
                    var theLocation = LocationBounded.FromDegrees(location.Latitude, location.Longitude);

                    var boundingBox = theLocation.BoundingCoordinates(location.Distance);

                    if (boundingBox.Length != 2)
                    {
                        throw new Exception("The bounding box is not in the correct format.");
                    }

                    var bottomLeft = boundingBox[0].ConvertToLatLonLocation();
                    var topRight = boundingBox[1].ConvertToLatLonLocation();

                    var hotels = unitOfWork.Hotels.GetHotelsInRadius(currentUserId, bottomLeft, topRight, location.Distance).ToList();

                    var outgoingHotels = hotels.Select(x => OutgoingHotel.Parse(x)).ToList();

                    return JsonFactory.CreateJsonMessage(outgoingHotels, HttpStatusCode.OK, this.Request);
                }
            }, this.Request));
        }
        public async Task <HttpResponseMessage> ForgotPassword(string email)
        {
            return(await ErrorFactory.Handle(async() =>
            {
                if (string.IsNullOrWhiteSpace(email))
                {
                    throw new InvalidModelException();
                }


                var user = await UserManager.FindByEmailAsync(email);

                if (user == null)
                {
                    return JsonFactory.CreateJsonMessage(new OutgoingMessage {
                        Message = "ok"
                    }, HttpStatusCode.OK, this.Request);
                }

                var token = await UserManager.GeneratePasswordResetTokenAsync(user.Id);

                await this.SendForgotPasswordEmail(user, token);

                return JsonFactory.CreateJsonMessage(new OutgoingMessage {
                    Message = "ok"
                }, HttpStatusCode.OK, this.Request);
            }, this.Request));
        }
        public async Task <HttpResponseMessage> ChangePassword(IncomingChangePassword model)
        {
            return(await ErrorFactory.Handle(async() =>
            {
                var userID = User.Identity.GetUserId();

                if (userID == null)
                {
                    throw new Exception();
                }

                var pwResult = await UserManager.PasswordValidator.ValidateAsync(model.NewPassword);

                if (pwResult.Succeeded == false)
                {
                    return JsonFactory.CreateJsonMessage(new OutgoingMessage {
                        Message = "Invalid password", Action = "invalidPassword"
                    }, HttpStatusCode.Forbidden, this.Request);
                }

                var result = await UserManager.ChangePasswordAsync(userID, model.CurrentPassword, model.NewPassword);

                if (result.Succeeded == false)
                {
                    return JsonFactory.CreateJsonMessage(new OutgoingMessage {
                        Message = "Invalid username password combo", Action = "invalidUsernamePassword"
                    }, HttpStatusCode.Forbidden, this.Request);
                }

                return GetInformationForCurrentUserResponseMessage(userID);
            }, this.Request));
        }
示例#4
0
        /// <summary>
        /// 将当前对象转化为其他类型,转化失败返回null
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static TResult ToObject <TResult>(this object obj)
        {
            string json;
            var    provider = JsonFactory.GetProvider();

            if (provider == null)
            {
                return(default(TResult));
            }

            try
            {
                if (obj is string)
                {
                    json = obj.ToString();
                }
                else
                {
                    json = provider.SerializeObject(obj);
                }
                return(provider.DeserializeObject <TResult>(json));
            }
            catch (Exception)
            {
                return(default(TResult));
            }
        }
示例#5
0
        private IManageFile GetManageFile(EnumType fileType)
        {
            IStudentFactory abstractFactory;

            switch (fileType)
            {
            case EnumType.TXT:
            {
                abstractFactory = new TxtFactory();
                return(abstractFactory.Create());
            }

            case EnumType.XML:
            {
                abstractFactory = new XmlFactory();
                return(abstractFactory.Create());
            }

            default:
            {
                abstractFactory = new JsonFactory();
                return(abstractFactory.Create());
            }
            }
        }
示例#6
0
        public void JsonFactoryGetIgnoredPropertiesDoesntThrowANullReferenceException()
        {
            var propList = JsonFactory.GetIgnoredProperties(null);

            Assert.NotNull(propList);
            Assert.IsEmpty(propList);
        }
示例#7
0
        /// <summary>
        ///     Initializes the class.
        /// </summary>
        /// <param name="type">The type.</param>
        public static void InitializeClass(Type type)
        {
            Console.WriteLine(
                type.GetMembers(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public).Count());
            foreach (var member in GetFieldsAndProperties(type))
            {
                var valueType = member.GetMemberType();
                var import    = member.GetCustomAttribute <ResourceImportAttribute>();
                var value     = JsonFactory.JsonResource(import.File, valueType);
                if (import.Filter != null)
                {
                    if (
                        !import.Filter.GetInterfaces()
                        .Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IFilter <>)))
                    {
                        throw new Exception($"{nameof(import.Filter)} does not implement {nameof(IFilter)}");
                    }

                    var filterInstance = Activator.CreateInstance(import.Filter);
                    var apply          = import.Filter.GetMethod("Apply", BindingFlags.Public | BindingFlags.Instance);

                    value = apply.Invoke(filterInstance, new[] { value });
                }

                member.SetValue(null, value);
            }
        }
        public HttpResponseMessage CheckStatus(int id)
        {
            return(ErrorFactory.Handle(() =>
            {
                var userId = User?.Identity?.GetUserId();

                if (string.IsNullOrWhiteSpace(userId))
                {
                    throw new Exception();
                }

                using (var unitOfWork = new UnitOfWork())
                {
                    var reservation = unitOfWork.Reservations.CheckStatus(userId, id);


                    if (reservation == null)
                    {
                        return JsonFactory.CreateJsonMessage(null, HttpStatusCode.OK, this.Request);
                    }

                    unitOfWork.Complete();

                    var outgoingReservation = OutgoingMinimalReservationGroup.Parse(reservation);

                    return JsonFactory.CreateJsonMessage(outgoingReservation, HttpStatusCode.OK, this.Request);
                }
            }, this.Request));
        }
示例#9
0
        public void Serialize_Deserialize()
        {
            FleetTemplate fleetTemplate = new FleetTemplate();

            fleetTemplate.Add(new AGVTemplate()
            {
                IPV4String = "192.168.0.1", PoseDataString = "0,0,90"
            });
            fleetTemplate.Add(new AGVTemplate()
            {
                IPV4String = "192.168.0.2", PoseDataString = "10,0,90"
            });

            string json = fleetTemplate.ToJson();

            Assert.IsNotNull(json);

            string filePath = Path.GetTempFileName();

            File.WriteAllText(filePath, json);

            FleetTemplate fleetTemplateLoaded = JsonFactory.FleetTemplateFromFile(filePath);

            Assert.IsNotNull(fleetTemplateLoaded);
            CollectionAssert.IsNotEmpty(fleetTemplateLoaded.AGVTemplates);
        }
示例#10
0
        public void Save()
        {
            var unityPackageManifestPath = Path.Combine(Project.UnityProjectRoot, "Packages", "manifest.json");
            var factory = new JsonFactory <UnityPackageManifest>();

            factory.Serialize(unityPackageManifestPath, this);
        }
        public HttpResponseMessage GetUserReservations(IncomingGetUsersReservations model)
        {
            return(ErrorFactory.Handle(() =>
            {
                using (var unitOfWork = new UnitOfWork())
                {
                    var userId = User?.Identity?.GetUserId();

                    if (string.IsNullOrWhiteSpace(userId))
                    {
                        throw new Exception();
                    }

                    if (model == null)
                    {
                        throw new InvalidModelException();
                    }

                    var reservations = unitOfWork.Reservations.GetReservationsForUser(userId, model.UserId, model.StartDate, model.EndDate);


                    var outgoingReservations = reservations?.Select(x => OutgoingMinimalReservationGroupExtra.Parse(x));

                    return JsonFactory.CreateJsonMessage(outgoingReservations, HttpStatusCode.OK, this.Request);
                }
            }, this.Request));
        }
        public static void Default_0_GetInstance()
        {
            JsonFactory.Register <JsonFactoryImpl>();
            var jsonFactory = JsonFactory.GetInstance();

            Assert.NotNull(jsonFactory);
        }
示例#13
0
        private static Voice[] GetVoices()
        {
            Voice[] voices = null;
            var     audio  = Find.Any <InteractionAudio>();

            if (audio != null)
            {
                var userProfile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
                var assetsRoot  = Path.Combine(userProfile, "Box", "VR Initiatives", "Engineering", "Assets");
                var keyFile     = Path.Combine(assetsRoot, "DevKeys", "azure-speech.txt");
                if (File.Exists(keyFile))
                {
                    var lines         = File.ReadAllLines(keyFile);
                    var azureApiKey   = lines[0];
                    var azureRegion   = lines[1];
                    var cache         = audio.GetCachingStrategy();
                    var voicesDecoder = new JsonFactory <Voice[]>();
                    var voicesClient  = new VoicesClient(azureRegion, azureApiKey, voicesDecoder, cache);
                    var voicesTask    = voicesClient.GetVoicesAsync();
                    voices = voicesTask.Result;
                }
            }

            return(voices);
        }
示例#14
0
        public HttpResponseMessage SearchEmployees(IncomingHotelUserSearch userQuery)
        {
            return(ErrorFactory.Handle(() =>
            {
                var userId = User?.Identity?.GetUserId();

                if (userId == null)
                {
                    throw new Exception("User not found.");
                }

                if (userQuery == null)
                {
                    throw new InvalidModelException("hotelQuery cannot be null");
                }

                using (var unitOfWork = new UnitOfWork())
                {
                    var hotels = unitOfWork.Hotels.SearchHotelUsers(userId, userQuery.HotelId, userQuery.Query, userQuery.StartsWith, userQuery.NumberToGet);

                    var outgoingHotels = hotels.ToList().Select(x => OutgoingHotelUser.Parse(x)).ToList();

                    return JsonFactory.CreateJsonMessage(outgoingHotels, HttpStatusCode.OK, this.Request);
                }
            }, this.Request));
        }
示例#15
0
        public HttpResponseMessage EditVenue(IncomingEditVenue addVenue)
        {
            return(ErrorFactory.Handle(() =>
            {
                var userId = User?.Identity?.GetUserId();

                if (string.IsNullOrWhiteSpace(userId))
                {
                    throw new Exception();
                }

                using (var unitOfWork = new UnitOfWork())
                {
                    var editVenue = unitOfWork.Venues.EditVenue(userId, addVenue);

                    unitOfWork.Complete();

                    try
                    {
                        editVenue = unitOfWork.Venues.GetVenueById(userId, editVenue.Id);
                    }
                    catch (Exception)
                    {
                    }

                    var outgoingVenue = OutgoingVenue.Parse(editVenue);

                    return JsonFactory.CreateJsonMessage(outgoingVenue, HttpStatusCode.OK, this.Request);
                }
            }, this.Request));
        }
示例#16
0
        public static void Default_6_SerializeObject_WithList()
        {
            var jsonFactory = JsonFactory.GetInstance();

            Assert.NotNull(jsonFactory);
            var classList = new List <TestClass1>();
            var class1    = new TestClass1
            {
                TestBool1   = true,
                TestInt1    = 3,
                TestString1 = "test"
            };

            classList.Add(class1);
            var class2 = new TestClass1
            {
                TestInt1 = 5
            };

            classList.Add(class2);
            var result = jsonFactory.SerializeObject(classList);

            Assert.NotNull(result);
            Assert.Equal("[{\"TestBool1\":true,\"TestInt1\":3,\"TestLong1\":0,\"TestString1\":\"test\"},{\"TestBool1\":false,\"TestInt1\":5,\"TestLong1\":0,\"TestString1\":null}]", result);
        }
示例#17
0
        public HttpResponseMessage AddBlackout(Blackout blackout)
        {
            return(ErrorFactory.Handle(() =>
            {
                var userId = User?.Identity?.GetUserId();

                if (string.IsNullOrWhiteSpace(userId))
                {
                    throw new Exception();
                }

                using (var unitOfWork = new UnitOfWork())
                {
                    var bl = unitOfWork.Venues.CreateBlackout(userId, blackout);

                    unitOfWork.Complete();

                    var outBl = new Blackout
                    {
                        Id = bl.Id,
                        StartDate = bl.StartDate,
                        EndDate = bl.EndDate,
                        VenueId = bl.VenueId
                    };

                    var outgoingBlackout = OutgoingVenueBlackout.Parse(outBl);

                    return JsonFactory.CreateJsonMessage(outgoingBlackout, HttpStatusCode.OK, this.Request);
                }
            }, this.Request));
        }
示例#18
0
        public void Default_6_SerializeObject_WithListOfDictionary()
        {
            var jsonFactory = JsonFactory.GetInstance();

            Assert.NotNull(jsonFactory);
            var dict = new Dictionary <string, string>
            {
                { "testKey0", "testValue0" },
                { "testKey1", "testValue1" },
                { "testKey2", "testValue2" }
            };
            var dict2 = new Dictionary <string, string>
            {
                { "testKey0", "testValue3" },
                { "testKey2", "testValue4" },
                { "testKey4", "testValue5" }
            };
            var dictList = new List <Dictionary <string, string> >
            {
                dict,
                dict2
            };
            var result = jsonFactory.SerializeObject(dictList);

            _output.WriteLine("Serialized string: " + result);
            Assert.Equal("[{\"testKey0\":\"testValue0\",\"testKey1\":\"testValue1\",\"testKey2\":\"testValue2\"},{\"testKey0\":\"testValue3\",\"testKey2\":\"testValue4\",\"testKey4\":\"testValue5\"}]", result);
        }
示例#19
0
        public void JsonFactoryGetIgnoredPropertiesReturnsListOfIgnoredProperties()
        {
            var propList   = JsonFactory.GetIgnoredProperties(new SampleSObject());
            var ignoreList = string.Join(", ", propList.OrderBy(p => p));

            Assert.AreEqual("IgnoredDate, IgnoredString", ignoreList);
        }
示例#20
0
        public static void Default_7_DeserializeObject()
        {
            var jsonFactory = JsonFactory.GetInstance();

            Assert.NotNull(jsonFactory);
            var class1 = new TestClass1
            {
                TestBool1   = true,
                TestInt1    = 3,
                TestLong1   = 10,
                TestString1 = "test"
            };
            var result = jsonFactory.SerializeObject(class1);

            Assert.NotNull(result);
            Assert.Equal("{\"TestBool1\":true,\"TestInt1\":3,\"TestLong1\":10,\"TestString1\":\"test\"}", result);
            var deserializedClass1 = jsonFactory.DeserializeObject <TestClass1>(result);

            Assert.Equal(class1.TestBool1, deserializedClass1.TestBool1);
            Assert.Equal(class1.TestInt1, deserializedClass1.TestInt1);
            Assert.Equal(class1.TestLong1, deserializedClass1.TestLong1);
            Assert.Equal(class1.TestString1, deserializedClass1.TestString1);

            class1 = new TestClass1
            {
                TestLong1 = 1000000000000
            };
            result             = jsonFactory.SerializeObject(class1);
            deserializedClass1 = jsonFactory.DeserializeObject <TestClass1>(result);
            Assert.Equal(class1.TestLong1, deserializedClass1.TestLong1);
        }
示例#21
0
    public void SaveData()
    {
        Dictionary <int, Tile> tile_map      = mTileMap.GetTileMap();
        List <int>             map_tile_list = new List <int>();

        for (int i = 0; i < Const.TileCntY; i++)
        {
            for (int j = 0; j < Const.TileCntX; j++)
            {
                int  index = (i * Const.TileCntX) + j;
                Tile tile  = null;
                if (tile_map.ContainsKey(index))
                {
                    tile = tile_map[index];
                }

                if (tile == null)
                {
                    map_tile_list.Add(0);
                }
                else
                {
                    map_tile_list.Add((int)tile.GetTileType());
                }
            }
        }

        MapData map_data = new MapData();

        map_data.MapName = Const.MapDataName;
        map_data.MapDta  = map_tile_list;

        JsonFactory.Write(Const.MapDataName, map_data);
    }
示例#22
0
        public static void JsonArray_05_ParseLong()
        {
            var jsonFactory = JsonFactory.GetInstance();

            Assert.NotNull(jsonFactory);
            var jsonArray = jsonFactory.CreateJsonArray();

            Assert.NotNull(jsonArray);
            Assert.Equal("[]", jsonArray.ToString());
            jsonArray.Insert(0, 100000000000L);
            var value = jsonArray.ParseLong(0);

            Assert.Equal(100000000000L, value);
            jsonArray.Insert(1, "200000000001");
            var value2 = jsonArray.ParseLong(1);

            Assert.Equal(200000000001L, value2);
            jsonArray.Insert(1, 300000000002L);
            var value3 = jsonArray.ParseLong(1);

            Assert.Equal(300000000002, value3);
            jsonArray.Insert(1, 1);
            var value4 = jsonArray.ParseLong(1);

            Assert.Equal(1L, value4);
        }
示例#23
0
        /// <summary>
        /// Dumps the configuration of hierarchy of queues with
        /// the xml file path given.
        /// </summary>
        /// <remarks>
        /// Dumps the configuration of hierarchy of queues with
        /// the xml file path given. It is to be used directly ONLY FOR TESTING.
        /// </remarks>
        /// <param name="out">the writer object to which dump is written to.</param>
        /// <param name="configFile">the filename of xml file</param>
        /// <exception cref="System.IO.IOException"/>
        internal static void DumpConfiguration(TextWriter @out, string configFile, Configuration
                                               conf)
        {
            if (conf != null && conf.Get(DeprecatedQueueConfigurationParser.MapredQueueNamesKey
                                         ) != null)
            {
                return;
            }
            JsonFactory              dumpFactory   = new JsonFactory();
            JsonGenerator            dumpGenerator = dumpFactory.CreateJsonGenerator(@out);
            QueueConfigurationParser parser;
            bool aclsEnabled = false;

            if (conf != null)
            {
                aclsEnabled = conf.GetBoolean(MRConfig.MrAclsEnabled, false);
            }
            if (configFile != null && !string.Empty.Equals(configFile))
            {
                parser = new QueueConfigurationParser(configFile, aclsEnabled);
            }
            else
            {
                parser = GetQueueConfigurationParser(null, false, aclsEnabled);
            }
            dumpGenerator.WriteStartObject();
            dumpGenerator.WriteFieldName("queues");
            dumpGenerator.WriteStartArray();
            DumpConfiguration(dumpGenerator, parser.GetRoot().GetChildren());
            dumpGenerator.WriteEndArray();
            dumpGenerator.WriteEndObject();
            dumpGenerator.Flush();
        }
示例#24
0
    void SetSocket()
    {
        // 소켓 설치
        gameObject.AddComponent <ClientNet>();
        mNet = GetComponent <ClientNet>();

        // @request UID 발급 신청
        StructRequest request = new StructRequest();

        request.uid         = "";
        request.request_url = URL.InitUser.ToString();

        void CallBack(StructRequest response)
        {
            if (response.uid != null)
            {
                mUserData           = new StructUserData();
                mUserData.uid       = response.uid;
                mUserData.isPVPMode = true;
                string map_data  = response.parameter["mapData"];
                string item_data = response.parameter["itemData"];

                // 맵 데이터에 저장
                JsonFactory.WriteString(Const.MapDataName, map_data);
                mUserData.itemData = item_data;
            }
        }

        mNet.SetCallBack(CallBack);
        mNet.RequestMsg(request);
    }
        public async Task <HttpResponseMessage> Login(IncomingLogin credentials)
        {
            return(await ErrorFactory.Handle(async() =>
            {
                var result = await SignInManager.PasswordSignInAsync(credentials.Email, credentials.Password, credentials.RememberMe, shouldLockout: true);

                switch (result)
                {
                case SignInStatus.Success:
                    ApplicationUser user = await UserManager.FindByNameAsync(credentials.Email);
                    return GetInformationForCurrentUserResponseMessage(user.Id);

                case SignInStatus.LockedOut:
                    return JsonFactory.CreateJsonMessage(new OutgoingMessage {
                        Message = "Your account is locked out. Please try again later.", Action = "lockedOut"
                    }, HttpStatusCode.Forbidden, Request);

                case SignInStatus.RequiresVerification:
                    return JsonFactory.CreateJsonMessage(new OutgoingMessage {
                        Message = "Your email requires verification. Please check your email and follow the instructions.", Action = "verificationRequired"
                    }, HttpStatusCode.Forbidden, this.Request);

                case SignInStatus.Failure:
                default:
                    return JsonFactory.CreateJsonMessage(new OutgoingMessage {
                        Message = "Invalid username/password combination", Action = "invalidCredentials"
                    }, HttpStatusCode.Forbidden, this.Request);
                }
            }, this.Request));
        }
示例#26
0
    // PVP
    public void GotoPVPGame()
    {
        // @request 상대 UID 요청
        StructRequest request = new StructRequest();

        request.uid         = mUserData.uid;
        request.request_url = URL.GetOpponentData.ToString();

        void mCallBack(StructRequest response)
        {
            if (response.parameter != null)
            {
                if (response.parameter["opponentUid"] != null)
                {
                    StructUserData user_data = mUserData;
                    user_data.opponentUid = response.parameter["opponentUid"];

                    // 발급받은 UID는 로컬 데이터에 저장
                    JsonFactory.Write(Const.UserDataName, user_data);

                    // 상대 클라이언트가 준비되었다면 게임 실행
                    SceneManager.LoadScene("GameScene");
                }
            }
        }

        mNet.SetCallBack(mCallBack);
        mNet.RequestMsg(request);
    }
        private HttpResponseMessage GetInformationForCurrentUserResponseMessage(string userID)
        {
            if (string.IsNullOrWhiteSpace(userID))
            {
                try
                {
                    LogoutNoRoute();
                }
                catch (Exception)
                {
                }

                return(JsonFactory.CreateJsonMessage(new OutgoingMessage {
                    Message = "An unknown error has occured.", Action = "unknownError"
                }, HttpStatusCode.Forbidden, this.Request));
            }

            using (var unitOfWork = new UnitOfWork())
            {
                var realUserInformation = unitOfWork.Users.GetUserByIdForLogin(userID, userID);

                if (realUserInformation == null)
                {
                    return(JsonFactory.CreateJsonMessage(new OutgoingMessage {
                        Message = "An unknown error has occured.", Action = "unknownError"
                    }, HttpStatusCode.Forbidden, this.Request));
                }

                var outgoingInformation = OutgoingPersonalUser.Parse(realUserInformation);

                return(JsonFactory.CreateJsonMessage(outgoingInformation, HttpStatusCode.OK, this.Request));
            }
        }
        public HttpResponseMessage GetMessagesForUser(int numberOfDays)
        {
            return(ErrorFactory.Handle(() =>
            {
                var userId = User.Identity.GetUserId();

                if (userId == null)
                {
                    throw new Exception();
                }

                if (numberOfDays <= 0)
                {
                    throw new Exception();
                }

                using (var unitOfWork = new UnitOfWork())
                {
                    var response = unitOfWork.Miscellaneous.GetMessagesForNumberOfDays(userId, numberOfDays);

                    var outgoingResponse = response?.Select(x => OutgoingInboxMessage.Parse(x))?.ToList();

                    return JsonFactory.CreateJsonMessage(outgoingResponse, HttpStatusCode.OK, this.Request);
                }
            }, this.Request));
        }
示例#29
0
    void SetUserData()
    {
        string         data  = JsonFactory.Load(Const.UserDataName);
        StructUserData _data = JsonUtility.FromJson <StructUserData>(data);

        Const.UserData = _data;
    }
示例#30
0
 //[DebuggerStepThrough]
 public static async Task <HttpResponseMessage> Handle(Func <Task <HttpResponseMessage> > functionToRun, HttpRequestMessage request)
 {
     try
     {
         return(await functionToRun());
     }
     catch (BeginTransactionException e)
     {
         return(JsonFactory.CreateJsonMessage(e.Summary, HttpStatusCode.InternalServerError, request));
     }
     catch (AlreadyDisposedException e)
     {
         return(JsonFactory.CreateJsonMessage(new OutgoingMessage {
             Message = e.Message, DetailedMessage = e.DetailedMessage, Action = e.Action, DetailedAction = e.DetailedAction
         }, HttpStatusCode.InternalServerError, request));
     }
     catch (UnauthorizedAccessException)
     {
         return(JsonFactory.CreateJsonMessage(new OutgoingMessage {
             Message = "You are not authorized to view this content.", Action = "unauthorized"
         }, HttpStatusCode.Forbidden, request));
     }
     catch (BaseException e)
     {
         return(JsonFactory.CreateJsonMessage(new OutgoingMessage {
             Message = e.Message, DetailedMessage = e.DetailedMessage, Action = e.Action, DetailedAction = e.DetailedAction
         }, HttpStatusCode.InternalServerError, request));
     }
     catch (Exception e)
     {
         return(JsonFactory.CreateJsonMessage(new OutgoingMessage {
             Message = e.Message
         }, HttpStatusCode.InternalServerError, request));
     }
 }