Example #1
0
        public ResponseFunction Insert_Function(FunctionModel data)
        {
            ResponseFunction resp = new ResponseFunction();

            try
            {
                var _validate = Validate_MasterFunction(data);

                if (_validate != null)
                {
                    resp = _validate;
                }
                else
                {
                    var rest = _IFuncMenuRepository.Insert_Function(data);
                    resp.status  = rest >= 0 ? StatusResponse.Success : StatusResponse.Error;
                    resp.message = rest >= 0 ? "Insert Successfull." : "Insert Fail.";
                }
                return(resp);
            }
            catch (Exception ex)
            {
                _ILogs.LogError("Function Service: ", ex.Message.ToString(), ex.StackTrace);
            }
            return(null);
        }
Example #2
0
 private void StartTransition(string name, float duration,
                              ResponseFunction onFinish = null)
 {
     if (inTransition)
     {
         return;
     }
     anim.SetTrigger(name);
     inTransition   = true;
     transitionTime = duration;
     Finish        += onFinish;
 }
Example #3
0
        public ResponseFunction Validate_MasterFunction(FunctionModel data)
        {
            ResponseFunction resp = new ResponseFunction();

            try
            {
                if (string.IsNullOrEmpty(data.code))
                {
                    resp.status  = StatusResponse.Error;
                    resp.message = "Code is required.";
                    return(resp);
                }
                if (string.IsNullOrEmpty(data.name_thai))
                {
                    resp.status  = StatusResponse.Error;
                    resp.message = "Name Thai is required.";
                    return(resp);
                }
                if (string.IsNullOrEmpty(data.name_eng))
                {
                    resp.status  = StatusResponse.Error;
                    resp.message = "Name English is required.";
                    return(resp);
                }
                if (string.IsNullOrEmpty(data.route_path))
                {
                    resp.status  = StatusResponse.Error;
                    resp.message = "Route Path is required.";
                    return(resp);
                }
                if (string.IsNullOrEmpty(data.icon_name))
                {
                    resp.status  = StatusResponse.Error;
                    resp.message = "Icon Name is required.";
                    return(resp);
                }
                if (string.IsNullOrEmpty(data.func_type))
                {
                    resp.status  = StatusResponse.Error;
                    resp.message = "Function Type is required.";
                    return(resp);
                }
            }
            catch (Exception ex)
            {
                _ILogs.LogError("Validate Function Service: ", ex.Message.ToString(), ex.StackTrace);
            }
            return(null);
        }
Example #4
0
        public ActionResult GetListFunction()
        {
            var _data = _IFuncMenuService.GetListFunction();

            if (_data != null)
            {
                ResponseFunction resp = new ResponseFunction()
                {
                    status  = StatusResponse.Success,
                    message = "success.",
                    data    = _data,
                };
                return(Ok(new { resp }));
            }
            else
            {
                return(BadRequest());
            }
        }
        public static bool Collide(Collision collider1, Collision collider2, CollisionType Type = CollisionType.Box, ResponseFunction f = null)
        {
            switch (Type)
            {
                case CollisionType.Circle:
                    if (CollisionListener.CircleCollision(collider1.Circle, collider2.Circle))
                    {
                        return callResponse(f);
                    }
                    break;
                case CollisionType.Polygon:
                    if (CollisionListener.BoxCollision(collider1.Box, collider2.Box))
                    {
                        if (CollisionListener.PolygonCollision(collider1.Polygon, collider2.Polygon))
                        {
                            return callResponse(f);
                        }
                    }
                    break;
                case CollisionType.Pixel:
                    if (CollisionListener.BoxCollision(collider1.Box, collider2.Box))
                    {
                        if (CollisionListener.PixelCollision(collider1.Transform, collider1.RenderBox, collider1.ColourData, collider2.Transform, collider2.RenderBox, collider2.ColourData))
                        {
                            return callResponse(f);
                        }
                    }
                    break;
                default:
                    if (CollisionListener.BoxCollision(collider1.Box, collider2.Box))
                    {
                        return callResponse(f);
                    }
                    break;
            }

            return false;
        }
        private static bool callResponse(ResponseFunction f)
        {
            if (f != null)
                f();

            return true;
        }
Example #7
0
        public ActionResult DeleteFunction([FromBody] FunctionModel data)
        {
            ResponseFunction resp = _IFuncMenuService.Delete_Function(data);

            return(Ok(new { resp }));
        }
Example #8
0
        public static Dictionary <string, ResponseFunction> BuildResponseFunctions(IActionsServer actions)
        {
            var _responseFunctions = new Dictionary <string, ResponseFunction>();

            // TODO: can probably use reflection or something fancier than all of this

            ResponseFunction resFunc = async delegate(MySocket socket, JObject json)
            {
                var sessionName = json.GetValue("sessionName").ToObject <string>();
                await actions.JoinSession(socket, sessionName);
            };

            _responseFunctions.Add("JoinSession", resFunc);

            resFunc = async delegate(MySocket socket, JObject json)
            {
                var media = json.GetValue("media").ToObject <MediaV1>();
                await actions.AddMediaToSession(socket, media);
            };
            _responseFunctions.Add("AddMediaToSession", resFunc);

            resFunc = async delegate(MySocket socket, JObject json)
            {
                var mediaId = json.GetValue("mediaId").ToObject <int>();
                await actions.DeleteMediaFromSession(socket, mediaId);
            };
            _responseFunctions.Add("DeleteMediaFromSession", resFunc);

            resFunc = async delegate(MySocket socket, JObject json)
            {
                var userId  = json.GetValue("userId").ToObject <int>();
                var newName = json.GetValue("newName").ToObject <string>();
                await actions.SaveUserNameChange(socket, userId, newName);
            };
            _responseFunctions.Add("SaveUserNameChange", resFunc);

            resFunc = async delegate(MySocket socket, JObject json)
            {
                var userName    = json.GetValue("userName").ToObject <string>();
                var chatMessage = json.GetValue("chatMessage").ToObject <string>();
                await actions.ChatMessage(socket, userName, chatMessage);
            };
            _responseFunctions.Add("ChatMessage", resFunc);

            resFunc = async delegate(MySocket socket, JObject json)
            {
                var userIdRequestee = json.GetValue("userIdRequestee").ToObject <int>();
                await actions.RequestSyncWithUser(socket, userIdRequestee);
            };
            _responseFunctions.Add("RequestSyncWithUser", resFunc);

            resFunc = async delegate(MySocket socket, JObject json)
            {
                var userIdRequestor = json.GetValue("userIdRequestor").ToObject <int>();
                var userState       = json.GetValue("userState").ToObject <UserStateV1>();
                await actions.ProvideSyncToUser(socket, userIdRequestor, userState);
            };
            _responseFunctions.Add("ProvideSyncToUser", resFunc);

            resFunc = async delegate(MySocket socket, JObject json)
            {
                var query = json.GetValue("query").ToObject <string>();
                var page  = json.GetValue("page").ToObject <int>();
                await actions.Search(socket, query, page);
            };
            _responseFunctions.Add("Search", resFunc);

            return(_responseFunctions);
        }
 public void FadeToDark(ResponseFunction onFinish)
 {
     StartTransition("ToDark", 1.0f, onFinish);
 }
 public void FadeToEmpty(ResponseFunction onFinish)
 {
     StartTransition("ToEmpty", 1.0f, onFinish);
 }
 private void StartTransition(string name, float duration,
                              ResponseFunction onFinish = null)
 {
     if (inTransition) return;
     anim.SetTrigger(name);
     inTransition = true;
     transitionTime = duration;
     Finish += onFinish;
 }
 public void ImageOut(ResponseFunction onFinish)
 {
     StartTransition("ImageOut", 0.5f, onFinish);
 }
 public void FadeToWhite(ResponseFunction onFinish)
 {
     StartTransition("ToWhite", 1.0f, onFinish);
 }
Example #14
0
 public void ImageOut(ResponseFunction onFinish)
 {
     StartTransition("ImageOut", 0.5f, onFinish);
 }
Example #15
0
 public void FadeToDark(ResponseFunction onFinish)
 {
     StartTransition("ToDark", 1.0f, onFinish);
 }
Example #16
0
 public void FadeToEmpty(ResponseFunction onFinish)
 {
     StartTransition("ToEmpty", 1.0f, onFinish);
 }