Example #1
0
    void LoadFBXItem()
    {
        DirectoryInfo d = new DirectoryInfo(Application.dataPath + "/Resources/FBX/");

        FileInfo[] info  = d.GetFiles();
        int        count = 0;

        for (int i = 0; i < info.Length; i++)
        {
            if (info[i].Name.Contains(".meta"))
            {
                continue;
            }
            GameObject temp = GameObject.Instantiate(Resources.Load(itemStr)) as GameObject;
            temp.transform.parent        = toggleGroup.transform;
            temp.transform.localPosition = new Vector3(0, -150 * (count + 1), 0);
            count++;
            Toggle tog = temp.GetComponent <Toggle>();
            tog.group = toggleGroup;
            ToggleModel tm = new ToggleModel();
            tm.itemName = info[i].Name.Remove(info[i].Name.Length - 4);
            Text text = TransformExtension.FindComponent <Text>(temp.transform, "Label");
            text.text = tm.itemName;
            tm.toggle = tog;

            UnityAction <bool> ua = tm.Click;
            temp.GetComponent <Toggle>().onValueChanged.AddListener(ua);
        }
        RectTransform rf = (RectTransform)toggleGroup.transform;

        rf.SetHeight(count * 150 + 150);
    }
Example #2
0
        public bool SetLive(ToggleModel model)
        {
            try
            {
                if (IsAuthor(model.Id) == false) // Cannot modify
                {
                    return(false);
                }

                var entity = _uow.Quizzes.GetById(model.Id);
                if (entity != null)
                {
                    entity.IsLive = model.Value;
                    _uow.Quizzes.Update(entity);

                    if (entity.IsLive == true)
                    {
                        _notificationSvc.DepQuizzNotificationSvc.AddDepQuizzLiveNotification(model.Id, false);
                        _activitySvc.QuizzActivitySvc.AddQuizzLiveActivity(model.Id, false);
                    }

                    _uow.SaveChanges();
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                _svcContainer.LoggingSvc.Log(ex);
                return(false);
            }
        }
        public bool CreatePermission(ToggleServicePermissionModel toggleServicePermissionModel)
        {
            if (toggleServicePermissionModel == null)
            {
                return(false);
            }

            try
            {
                ToggleModel  toggleModel  = ToggleRepository.GetToggle(toggleServicePermissionModel.ToggleId);
                ServiceModel serviceModel = ServiceRepository.GetService(toggleServicePermissionModel.ServiceId);

                if (toggleModel != null && serviceModel != null)
                {
                    TogglerContext.ToggleServicePermissions.Add(toggleServicePermissionModel);
                    TogglerContext.SaveChanges();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                Logger.LogFile($"Failed to create the ToggleServicePermission: {ex.Message}");
            }

            return(false);
        }
Example #4
0
        public ToggleResponseModel GetToggle(int id)
        {
            try
            {
                ToggleModel toggleModel = ToggleRepository.GetToggle(id);

                if (toggleModel != null)
                {
                    ToggleResponseModel toggleResponseModel = new ToggleResponseModel()
                    {
                        ToggleId = toggleModel.ToggleId,
                        Name     = toggleModel.Name,
                        Value    = toggleModel.Value
                    };

                    return(toggleResponseModel);
                }
            }
            catch (Exception ex)
            {
                Logger.LogFile($"Error getting a Toggle by id = {id}: {ex.Message}");
            }

            return(null);
        }
Example #5
0
        public bool UpdateToggle(ToggleRequestModel toggleRequestModel)
        {
            if (toggleRequestModel?.ToggleId == null || string.IsNullOrWhiteSpace(toggleRequestModel.Name))
            {
                return(false);
            }

            try
            {
                ToggleModel toggleModel = new ToggleModel()
                {
                    ToggleId = (int)toggleRequestModel.ToggleId,
                    Name     = toggleRequestModel.Name,
                    Value    = toggleRequestModel.Value
                };

                return(ToggleRepository.UpdateToggle(toggleModel));
            }
            catch (Exception ex)
            {
                Logger.LogFile($"Error updating a Toggle: {ex.Message}");
            }

            return(false);
        }
Example #6
0
        public bool UpdateToggle(ToggleModel toggleModel)
        {
            if (toggleModel == null || string.IsNullOrWhiteSpace(toggleModel.Name))
            {
                return(false);
            }

            try
            {
                ToggleModel toggle = TogglerContext.Toggles.Find(toggleModel.ToggleId);

                if (toggle != null)
                {
                    toggle.Name  = toggleModel.Name;
                    toggle.Value = toggleModel.Value;

                    TogglerContext.Toggles.Update(toggle);
                    TogglerContext.SaveChanges();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                Logger.LogFile($"Failed to update the Toggle: {ex.Message}");
            }

            return(false);
        }
        public HttpResponseMessage Patch([FromBody] ToggleModel model)
        {
            try
            {
                if (ModelState.IsValid == false || _quizzSvc.SetLive(model) == false)
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest));
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (ServiceException ex)
            {
                return(Request.CreateResponse(ex.HttpStatusCode, ex.Message));
            }
        }
Example #8
0
        public async Task <IActionResult> ToggleImage([FromBody] ToggleModel model)
        {
            var tokmojis = PurchasesTool.GetProducts().Where(x => x.ProductType == ProductType.Tokmoji).ToList();

            model.Text = model.Text.TrimEnd('\r', '\n');
            foreach (var item in tokmojis)
            {
                if (model.ShowImage)
                {
                    model.Text = model.Text.Replace(":" + item.Id + ":", "<img src='" + item.Image + "' style='height: 32px;' data-toggle='tooltip' data-title='" + item.Id + "'/>");
                }
                else
                {
                    model.Text = model.Text.Replace(":" + item.Image + ":", ":" + item.Id + ":");
                }
            }
            return(Json(model.Text));
        }
Example #9
0
        public int CreateToggle(ToggleModel toggleModel)
        {
            if (toggleModel == null || string.IsNullOrWhiteSpace(toggleModel.Name))
            {
                return(Invalid);
            }

            try
            {
                TogglerContext.Toggles.Add(toggleModel);
                TogglerContext.SaveChanges();

                return(toggleModel.ToggleId);
            }
            catch (Exception ex)
            {
                Logger.LogFile($"Failed to create the Toggle: {ex.Message}");

                return(Invalid);
            }
        }
Example #10
0
        public bool DeleteToggle(int id)
        {
            try
            {
                ToggleModel toggerModel = TogglerContext.Toggles.Find(id);

                if (toggerModel != null)
                {
                    TogglerContext.Toggles.Attach(toggerModel);
                    TogglerContext.Toggles.Remove(toggerModel);
                    TogglerContext.SaveChanges();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                Logger.LogFile($"Failed to delete the Toggle: {ex.Message}");
            }

            return(false);
        }
Example #11
0
        public int CreateToggle(ToggleRequestModel toggleRequestModel)
        {
            if (toggleRequestModel == null || string.IsNullOrWhiteSpace(toggleRequestModel.Name))
            {
                return(Invalid);
            }

            try
            {
                ToggleModel toggleModel = new ToggleModel()
                {
                    Name  = toggleRequestModel.Name,
                    Value = toggleRequestModel.Value
                };

                return(ToggleRepository.CreateToggle(toggleModel));
            }
            catch (Exception ex)
            {
                Logger.LogFile($"Error creating a Toggle: {ex.Message}");

                return(Invalid);
            }
        }