Beispiel #1
0
 public Task ClickRandomPoint(BoxModel box, Random rng)
 {
     return(Click(
                rng.Next(box.ContentLeft, box.ContentRight),
                rng.Next(box.ContentTop, box.ContentBottom)
                ));
 }
    GameObject build_more_flyout()
    {
        GameObject popupGO = GameObject.Instantiate(Resources.Load <GameObject>("BasicToolMenu"));

        popupGO.SetName("MoreSceneMenu");

        CCUIBuilder.AddBasicToolButton(popupGO, "New Scene", on_clear_scene_clicked);

        Canvas.AddChild(popupGO, false);

        // [RMS] I have no idea what is going on here...but this does work

        RectTransform    targetRect  = moreButton.gameObject.GetComponent <RectTransform>();
        AxisAlignedBox2f targetBox   = targetRect.rect;
        Vector2f         targetPoint = BoxModel.GetBoxPosition(ref targetBox, BoxPosition.TopRight);
        Vector3f         targetW     = moreButton.gameObject.transform.TransformPoint(targetPoint.x, targetPoint.y, 0);

        //RectTransform popupRect = popupGO.GetComponent<RectTransform>();
        //AxisAlignedBox2f popupBox = popupRect.rect;
        //Vector2f popupCorner = BoxModel.GetBoxPosition(ref popupBox, BoxPosition.TopLeft);
        //Vector3f popupW = popupGO.transform.TransformPoint(popupCorner.x, popupCorner.y, 0);
        //Vector2f popupCenter = BoxModel.GetBoxPosition(ref popupBox, BoxPosition.Center);
        //Vector3f popupC = popupGO.transform.TransformPoint(popupCenter.x, popupCenter.y, 0);
        //Vector3f dl = popupW - popupC;

        //Vector3f dx = popupW - targetW;

        Vector3f shift = new Vector3f(5, 5, 0);

        popupGO.transform.position = targetW + shift;


        return(popupGO);
    }
Beispiel #3
0
        // Fill
        public string FillBoxModel(BoxModel boxModel, BoxModelModel boxModelModel, ContactOK contactOK)
        {
            boxModel.DBCommand = (int)boxModelModel.DBCommand;
            boxModel.InfrastructureTVItemID = boxModelModel.InfrastructureTVItemID;
            boxModel.Discharge_m3_day       = boxModelModel.Discharge_m3_day;
            boxModel.Depth_m                     = boxModelModel.Depth_m;
            boxModel.Temperature_C               = boxModelModel.Temperature_C;
            boxModel.Dilution                    = boxModelModel.Dilution;
            boxModel.DecayRate_per_day           = boxModelModel.DecayRate_per_day;
            boxModel.FCUntreated_MPN_100ml       = boxModelModel.FCUntreated_MPN_100ml;
            boxModel.FCPreDisinfection_MPN_100ml = boxModelModel.FCPreDisinfection_MPN_100ml;
            boxModel.Concentration_MPN_100ml     = boxModelModel.Concentration_MPN_100ml;
            boxModel.DischargeDuration_hour      = boxModelModel.DischargeDuration_hour;
            boxModel.T90_hour                    = boxModelModel.T90_hour;
            boxModel.LastUpdateDate_UTC          = DateTime.UtcNow;
            if (contactOK == null)
            {
                boxModel.LastUpdateContactTVItemID = 2;
            }
            else
            {
                boxModel.LastUpdateContactTVItemID = contactOK.ContactTVItemID;
            }

            return("");
        }
Beispiel #4
0
        public BoxModelModel PostDeleteBoxModelDB(int BoxModelID)
        {
            ContactOK contactOK = IsContactOK();

            if (!string.IsNullOrEmpty(contactOK.Error))
            {
                return(ReturnError(contactOK.Error));
            }

            BoxModel boxModelToDelete = GetBoxModelWithBoxModelIDDB(BoxModelID);

            if (boxModelToDelete == null)
            {
                return(ReturnError(string.Format(ServiceRes.CouldNotFind_ToDelete, ServiceRes.BoxModel)));
            }

            using (TransactionScope ts = new TransactionScope())
            {
                db.BoxModels.Remove(boxModelToDelete);
                string retStr = DoDeleteChanges();
                if (!string.IsNullOrWhiteSpace(retStr))
                {
                    return(ReturnError(retStr));
                }

                LogModel logModel = _LogService.PostAddLogForObj("BoxModels", boxModelToDelete.BoxModelID, LogCommandEnum.Delete, boxModelToDelete);
                if (!string.IsNullOrWhiteSpace(logModel.Error))
                {
                    return(ReturnError(logModel.Error));
                }

                ts.Complete();
            }
            return(ReturnError(""));
        }
Beispiel #5
0
        //Output information of created box
        public ActionResult RequestBox(BoxModel viewModel)
        {
            //Show a view consisting of the fields of the box
            if (ModelState.IsValid)
            {
                string message = string.Format("The request for box with with size {0}:{1}:{2} and weight {3}, color {4} and material {5} was successfully accepted."
                                               , viewModel.Width, viewModel.Height, viewModel.Length, viewModel.Weight, viewModel.Colour, viewModel.Material);

                //Create DTO
                BoxDTO box = new BoxDTO();
                //Set Properties of DTO
                foreach (PropertyInfo property in box.GetType().GetProperties())
                {
                    property.SetValue(box, viewModel.GetType().GetProperty(property.Name).GetValue(viewModel));
                }
                _service.Insert(box);

                ViewBag.SuccessMessage = message;
                return(View());
            }
            //Go back to creating a box, because something was not valid
            else
            {
                TempData["viewModel"] = viewModel;
                return(RedirectToAction("Create"));
            }
        }
        public BubbleModel CreateEasy()
        {
            BubbleModel bubbleModel = new BubbleModel();

            BoxModel boxModel = new BoxModel()
            {
                layout = FlexLayout.vertical
            };
            List <FlexComponentModel> boxModelContentsList = new List <FlexComponentModel>();
            TextModel textModel1 = new TextModel()
            {
                text = "hello"
            };
            TextModel textModel2 = new TextModel()
            {
                text = "world"
            };

            boxModelContentsList.Add(textModel1);
            boxModelContentsList.Add(textModel2);

            boxModel.contents = boxModelContentsList;

            bubbleModel.body = boxModel;

            return(bubbleModel);
        }
Beispiel #7
0
    public void UpdateItemDate()
    {
        List <BoxModel> boxList = PlayerPrefsUtil.ContentModel.boxList;

        for (int i = 0; i < boxList.Count; i++)
        {
            GameObject item    = itemMonthList[i];
            BoxModel   box     = boxList[i];
            Image      imgThum = item.transform.Find("ImageMask").Find("Img_Thum").GetComponent <Image>();
            ImageDownloadUtils.Instance.SetAsyncImage(box.frontCover, imgThum);
            Text tvTitle = item.transform.Find("Tv_Title").GetComponent <Text>();
            tvTitle.text = box.name;
            Transform lockTr = item.transform.Find("ImageMask").Find("Img_Lock");
            item.GetComponent <Button>().onClick.RemoveAllListeners();
            item.GetComponent <Button>().onClick
            .AddListener(delegate { OnClick(box); });
            if (DoCheckIsLock(box.boxId))
            {
                lockTr.gameObject.SetActive(false);
            }
            else
            {
                lockTr.gameObject.SetActive(true);
            }
        }
    }
        private BoxModel GetFilledRandomBoxModel(string OmitPropName)
        {
            BoxModel boxModel = new BoxModel();

            if (OmitPropName != "InfrastructureTVItemID")
            {
                boxModel.InfrastructureTVItemID = 41;
            }
            if (OmitPropName != "Discharge_m3_day")
            {
                boxModel.Discharge_m3_day = GetRandomDouble(0.0D, 10000.0D);
            }
            if (OmitPropName != "Depth_m")
            {
                boxModel.Depth_m = GetRandomDouble(0.0D, 1000.0D);
            }
            if (OmitPropName != "Temperature_C")
            {
                boxModel.Temperature_C = GetRandomDouble(-15.0D, 40.0D);
            }
            if (OmitPropName != "Dilution")
            {
                boxModel.Dilution = GetRandomInt(0, 10000000);
            }
            if (OmitPropName != "DecayRate_per_day")
            {
                boxModel.DecayRate_per_day = GetRandomDouble(0.0D, 100.0D);
            }
            if (OmitPropName != "FCUntreated_MPN_100ml")
            {
                boxModel.FCUntreated_MPN_100ml = GetRandomInt(0, 10000000);
            }
            if (OmitPropName != "FCPreDisinfection_MPN_100ml")
            {
                boxModel.FCPreDisinfection_MPN_100ml = GetRandomInt(0, 10000000);
            }
            if (OmitPropName != "Concentration_MPN_100ml")
            {
                boxModel.Concentration_MPN_100ml = GetRandomInt(0, 10000000);
            }
            if (OmitPropName != "T90_hour")
            {
                boxModel.T90_hour = GetRandomDouble(0.0D, 10.0D);
            }
            if (OmitPropName != "DischargeDuration_hour")
            {
                boxModel.DischargeDuration_hour = GetRandomDouble(0.0D, 24.0D);
            }
            if (OmitPropName != "LastUpdateDate_UTC")
            {
                boxModel.LastUpdateDate_UTC = new DateTime(2005, 3, 6);
            }
            if (OmitPropName != "LastUpdateContactTVItemID")
            {
                boxModel.LastUpdateContactTVItemID = 2;
            }

            return(boxModel);
        }
Beispiel #9
0
        public BoxModel GetBoxModelWithBoxModelIDDB(int BoxModelID)
        {
            BoxModel boxModel = (from c in db.BoxModels
                                 where c.BoxModelID == BoxModelID
                                 select c).FirstOrDefault <BoxModel>();

            return(boxModel);
        }
Beispiel #10
0
 private void QuitBox()
 {
     StopCoroutine(ControlBox());
     rb.useGravity        = true;
     box.transform.parent = null;
     box          = null;
     boxIsCapture = false;
 }
Beispiel #11
0
        public void UpdateMonth()
        {
            SimpleEventSystem.Publish(new CanvasCanMove());
            var boxMonthIndex = PlayerPrefsUtil.GetBoxMonthIndex();

            BoxModel     = PlayerPrefsUtil.ContentModel.boxList[boxMonthIndex];
            TvTitle.text = BoxModel.name;
            mPlayer.GetComponent <MasterController>().SetData(BoxModel);
        }
        public void BoxModel_Controller_Put_Test()
        {
            foreach (LanguageEnum LanguageRequest in AllowableLanguages)
            {
                foreach (int ContactID in new List <int>()
                {
                    AdminContactID
                })                                                             //, TestEmailValidatedContactID, TestEmailNotValidatedContactID })
                {
                    BoxModelController boxModelController = new BoxModelController(DatabaseTypeEnum.SqlServerTestDB);
                    Assert.IsNotNull(boxModelController);
                    Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, boxModelController.DatabaseType);

                    BoxModel boxModelLast = new BoxModel();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        Query query = new Query();
                        query.Language = LanguageRequest;

                        BoxModelService boxModelService = new BoxModelService(query, db, ContactID);
                        boxModelLast = (from c in db.BoxModels select c).FirstOrDefault();
                    }

                    // ok with BoxModel info
                    IHttpActionResult jsonRet = boxModelController.GetBoxModelWithID(boxModelLast.BoxModelID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <BoxModel> Ret = jsonRet as OkNegotiatedContentResult <BoxModel>;
                    BoxModel boxModelRet = Ret.Content;
                    Assert.AreEqual(boxModelLast.BoxModelID, boxModelRet.BoxModelID);

                    BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult;
                    Assert.IsNull(badRequest);

                    // Put to return success
                    IHttpActionResult jsonRet2 = boxModelController.Put(boxModelRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <BoxModel> boxModelRet2 = jsonRet2 as OkNegotiatedContentResult <BoxModel>;
                    Assert.IsNotNull(boxModelRet2);

                    BadRequestErrorMessageResult badRequest2 = jsonRet2 as BadRequestErrorMessageResult;
                    Assert.IsNull(badRequest2);

                    // Put to return CSSPError because BoxModelID of 0 does not exist
                    boxModelRet.BoxModelID = 0;
                    IHttpActionResult jsonRet3 = boxModelController.Put(boxModelRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet3);

                    OkNegotiatedContentResult <BoxModel> boxModelRet3 = jsonRet3 as OkNegotiatedContentResult <BoxModel>;
                    Assert.IsNull(boxModelRet3);

                    BadRequestErrorMessageResult badRequest3 = jsonRet3 as BadRequestErrorMessageResult;
                    Assert.IsNotNull(badRequest3);
                }
            }
        }
Beispiel #13
0
 public void HideLoading()
 {
     if (BoxModel != null)
     {
         if (typeof(LoadingBoxViewModel) == BoxModel.GetType())
         {
             ((LoadingBoxViewModel)BoxModel).IsShow = false;
         }
     }
 }
Beispiel #14
0
        private BoxModel InitializeBox(float x, float y, float width, float height, float density)
        {
            BoxModelDef boxModelDef = new BoxModelDef();
            boxModelDef.Width = ConvertUnits.ToSimUnits(width);
            boxModelDef.Height = ConvertUnits.ToSimUnits(height);
            boxModelDef.Position = ConvertUnits.ToSimUnits(x, y);
            boxModelDef.Mass = density*boxModelDef.Width*boxModelDef.Height;

            BoxModel model = new BoxModel(boxModelDef);
            return model;
        }
Beispiel #15
0
        public BoxModel GetBoxModelWithInfrastructureTVItemIDAndScenarioNameDB(int InfrastructureTVItemID, string ScenarioName)
        {
            BoxModel boxModel = (from c in db.BoxModels
                                 from cl in db.BoxModelLanguages
                                 where c.BoxModelID == cl.BoxModelID &&
                                 c.InfrastructureTVItemID == InfrastructureTVItemID &&
                                 cl.ScenarioName == ScenarioName &&
                                 cl.Language == (int)LanguageRequest
                                 select c).FirstOrDefault <BoxModel>();

            return(boxModel);
        }
Beispiel #16
0
        private BoxView InitializeBoxView(BoxModel boxModel, Color fill, Color stroke, float strokeThickness)
        {
            Rectangle rectangle = ShapeFactory.CreateRectangle(ConvertUnits.ToDisplayUnits(boxModel.Width), ConvertUnits.ToDisplayUnits(boxModel.Height), fill, stroke, strokeThickness);

            Sprite sprite = new Sprite(rectangle);

            sprite.Origin = new Vector2(sprite.Width / 2, sprite.Height / 2);

            BoxView boxView = new BoxView(boxModel, sprite);

            return(boxView);
        }
        private BoxView InitializeBoxView(BoxModel boxModel, Color fill, Color stroke, float strokeThickness)
        {
            Rectangle rectangle = ShapeFactory.CreateRectangle(ConvertUnits.ToDisplayUnits(boxModel.Width),
                                                               ConvertUnits.ToDisplayUnits(boxModel.Height), fill,
                                                               stroke, strokeThickness);

            Sprite sprite = new Sprite(rectangle);
            sprite.Origin = new Vector2(sprite.Width/2, sprite.Height/2);

            BoxView boxView = new BoxView(boxModel, sprite);
            return boxView;
        }
        public void BoxModel_CRUD_Test()
        {
            foreach (CultureInfo culture in AllowableCulture)
            {
                ChangeCulture(culture);

                using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                {
                    BoxModelService boxModelService = new BoxModelService(new Query()
                    {
                        Lang = culture.TwoLetterISOLanguageName
                    }, dbTestDB, ContactID);

                    int count = 0;
                    if (count == 1)
                    {
                        // just so we don't get a warning during compile [The variable 'count' is assigned but its value is never used]
                    }

                    BoxModel boxModel = GetFilledRandomBoxModel("");

                    // -------------------------------
                    // -------------------------------
                    // CRUD testing
                    // -------------------------------
                    // -------------------------------

                    count = boxModelService.GetBoxModelList().Count();

                    Assert.AreEqual(count, (from c in dbTestDB.BoxModels select c).Count());

                    boxModelService.Add(boxModel);
                    if (boxModel.HasErrors)
                    {
                        Assert.AreEqual("", boxModel.ValidationResults.FirstOrDefault().ErrorMessage);
                    }
                    Assert.AreEqual(true, boxModelService.GetBoxModelList().Where(c => c == boxModel).Any());
                    boxModelService.Update(boxModel);
                    if (boxModel.HasErrors)
                    {
                        Assert.AreEqual("", boxModel.ValidationResults.FirstOrDefault().ErrorMessage);
                    }
                    Assert.AreEqual(count + 1, boxModelService.GetBoxModelList().Count());
                    boxModelService.Delete(boxModel);
                    if (boxModel.HasErrors)
                    {
                        Assert.AreEqual("", boxModel.ValidationResults.FirstOrDefault().ErrorMessage);
                    }
                    Assert.AreEqual(count, boxModelService.GetBoxModelList().Count());
                }
            }
        }
 public void SetData(BoxModel boxModel)
 {
     if (PlayerPrefsUtil.LockModels.Count <= PlayerPrefsUtil.GetBoxMonthIndex())
     {
         PlayerPrefsUtil.SaveBoxMonthIndex(0);
     }
     CurrentIndex  = PlayerPrefsUtil.GetUserDayPosition(boxModel);
     BoxMonthIndex = PlayerPrefsUtil.GetBoxMonthIndex();
     BoxModel      = boxModel;
     UnlockDays.Clear();
     UpdatePosition();
     UpdateItem(PlayerPrefsUtil.LockModels[BoxMonthIndex], boxModel.boxContentList);
 }
Beispiel #20
0
        /// <summary>
        /// invoke as an asynchronous operation.
        /// </summary>
        /// <param name="title">The title of the box</param>
        /// <param name="description">The description under the title</param>
        /// <param name="cssBackground">The CSS background.</param>
        /// <param name="fontawesomeIcon">The fontawesome icon.</param>
        /// <param name="shadow">The shadow type for the box</param>
        /// <returns>A Task&lt;IViewComponentResult&gt; representing the asynchronous operation.</returns>
        public async Task <IViewComponentResult> InvokeAsync(string title, string description,
                                                             string cssBackground, string fontawesomeIcon, ShadowType shadow = ShadowType.None)
        {
            BoxModel model = new BoxModel();

            model.BackgroundColor = cssBackground ?? null;
            model.Icon            = fontawesomeIcon ?? null;
            model.SubText         = description ?? string.Empty;
            model.Text            = title;
            model.Shadow          = shadow;

            return(View("Default", model));
        }
Beispiel #21
0
        protected override void OnClose()
        {
            AudioManager.SetMusicOff();
            mPlayer.DestroySelf();
            mPlayer = null;
            if (mResLoader.IsNotNull())
            {
                mResLoader.Recycle2Cache();
                mResLoader = null;
            }

            BoxModel = null;
        }
Beispiel #22
0
        public IHttpActionResult GetBoxModelWithID([FromUri] int BoxModelID, [FromUri] string lang = "en", [FromUri] string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                BoxModelService boxModelService = new BoxModelService(new Query()
                {
                    Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en)
                }, db, ContactID);

                boxModelService.Query = boxModelService.FillQuery(typeof(BoxModel), lang, 0, 1, "", "", extra);

                if (boxModelService.Query.Extra == "A")
                {
                    BoxModelExtraA boxModelExtraA = new BoxModelExtraA();
                    boxModelExtraA = boxModelService.GetBoxModelExtraAWithBoxModelID(BoxModelID);

                    if (boxModelExtraA == null)
                    {
                        return(NotFound());
                    }

                    return(Ok(boxModelExtraA));
                }
                else if (boxModelService.Query.Extra == "B")
                {
                    BoxModelExtraB boxModelExtraB = new BoxModelExtraB();
                    boxModelExtraB = boxModelService.GetBoxModelExtraBWithBoxModelID(BoxModelID);

                    if (boxModelExtraB == null)
                    {
                        return(NotFound());
                    }

                    return(Ok(boxModelExtraB));
                }
                else
                {
                    BoxModel boxModel = new BoxModel();
                    boxModel = boxModelService.GetBoxModelWithBoxModelID(BoxModelID);

                    if (boxModel == null)
                    {
                        return(NotFound());
                    }

                    return(Ok(boxModel));
                }
            }
        }
Beispiel #23
0
    protected virtual void Start()
    {
        Model = new BoxModel(Name, Settings, Game.Instance.PrincessCake.Settings);

        _logger = Game.Instance.LoggerFactory(name + "::BoxController");

        Collider collider = GetComponent <Collider>();

        if (collider == null)
        {
            collider = GetComponentInChildren <Collider>();
        }

        _logger.Assert(collider != null, "No collider was found at object. Make sure to assign one (.eg BoxCollider).");
    }
Beispiel #24
0
        public static List <BaseModel> MapContentColumn(Item item, Column column)
        {
            List <BaseModel> model = new List <BaseModel>();

            MultilistField contentItems = null;

            switch (column)
            {
            case Column.LEFT:
                contentItems = item.Fields[DropdownItemFields.LeftColumn];
                break;

            case Column.CENTAL:
                contentItems = item.Fields[DropdownItemFields.CentralColumn];
                break;

            case Column.RIGHT:
                contentItems = item.Fields[DropdownItemFields.RightColumn];
                break;
            }

            if (contentItems != null)
            {
                foreach (Item contentItem in contentItems.GetItems())
                {
                    if (contentItem.TemplateID == SiteTemplates.ContentBoxTemplaateId)
                    {
                        BoxModel boxModel = new BoxModel();
                        boxModel.Type    = ContentType.BOX;
                        boxModel.Topic   = contentItem[BoxItemFields.Topic];
                        boxModel.Content = contentItem[BoxItemFields.Content];
                        model.Add(boxModel);
                    }
                    else if (contentItem.TemplateID == SiteTemplates.ContentListTemplaateId)
                    {
                        ListModel listModel = new ListModel();
                        listModel.Type    = ContentType.LIST;
                        listModel.Topic   = contentItem[ListItemFields.Topic];
                        listModel.Content = contentItem[ListItemFields.Content];
                        model.Add(listModel);
                    }
                }
            }

            return(model);
        }
Beispiel #25
0
 private void CaptureBox()
 {
     ray = Camera.main.ScreenPointToRay(Input.mousePosition);
     if (!Physics.Raycast(ray, out hit) || hit.distance > 3f)
     {
         return;
     }
     if (hit.transform.GetComponent <BoxModel>())
     {
         box                  = hit.transform.GetComponent <BoxModel>();
         rb                   = box.GetComponent <Rigidbody>();
         rb.useGravity        = false;
         box.transform.parent = Camera.main.transform;
         StartCoroutine(ControlBox());
         boxIsCapture = true;
     }
 }
Beispiel #26
0
        /// <summary>
        /// Tries to execute the CSSPDB transaction (add/delete/update) on an [BoxModel](CSSPModels.BoxModel.html) item
        /// </summary>
        /// <param name="boxModel">Is the BoxModel item the client want to add to CSSPDB. What's important here is the BoxModelID</param>
        /// <returns>true if BoxModel item was updated to CSSPDB, false if an error happened during the DB requested transtaction</returns>
        private bool TryToSave(BoxModel boxModel)
        {
            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException ex)
            {
                boxModel.ValidationResults = new List <ValidationResult>()
                {
                    new ValidationResult(ex.Message + (ex.InnerException != null ? " Inner: " + ex.InnerException.Message : ""))
                }.AsEnumerable();
                return(false);
            }

            return(true);
        }
Beispiel #27
0
        //Edit box with a specified BoxModel
        public ActionResult Edit(BoxModel viewModel)
        {
            if (ModelState.IsValid)
            {
                BoxModel old = _models.Where(model => model.ID == viewModel.ID).FirstOrDefault();
                foreach (PropertyInfo property in old.GetType().GetProperties())
                {
                    property.SetValue(old, property.GetValue(viewModel));
                }

                return(RedirectToAction("List"));
            }
            else
            {
                return(RedirectToAction("Edit", new { id = viewModel.ID }));
            }
        }
Beispiel #28
0
        /// <summary>
        /// Updates an [BoxModel](CSSPModels.BoxModel.html) item in CSSPDB
        /// </summary>
        /// <param name="boxModel">Is the BoxModel item the client want to add to CSSPDB. What's important here is the BoxModelID</param>
        /// <returns>true if BoxModel item was updated to CSSPDB, false if an error happened during the DB requested transtaction</returns>
        public bool Update(BoxModel boxModel)
        {
            boxModel.ValidationResults = Validate(new ValidationContext(boxModel), ActionDBTypeEnum.Update);
            if (boxModel.ValidationResults.Count() > 0)
            {
                return(false);
            }

            db.BoxModels.Update(boxModel);

            if (!TryToSave(boxModel))
            {
                return(false);
            }

            return(true);
        }
Beispiel #29
0
    void Start()
    {
        var boxViews = FindObjectsOfType <BoxView>();

        _inputManager = new InputManager();

        var playerModel     = new PlayerModel();
        var playerViewModel = new PlayerViewModel(playerModel);

        foreach (var box in boxViews)
        {
            var boxModel     = new BoxModel();
            var boxViewModel = new BoxViewModel(boxModel);
            box.Initialize(boxViewModel);
        }

        playerView.Initialize(playerViewModel);
    }
Beispiel #30
0
        //Edit box with a specified BoxModel
        public ActionResult Edit(BoxModel viewModel)
        {
            if (ModelState.IsValid)
            {
                BoxDTO @new = new BoxDTO();
                foreach (PropertyInfo property in @new.GetType().GetProperties())
                {
                    property.SetValue(@new, viewModel.GetType().GetProperty(property.Name).GetValue(viewModel));
                }

                _service.Edit(@new);

                return(RedirectToAction("List"));
            }
            else
            {
                return(RedirectToAction("Edit", new { id = viewModel.ID }));
            }
        }
        public void BoxModel_Controller_GetBoxModelWithID_Test()
        {
            foreach (LanguageEnum LanguageRequest in AllowableLanguages)
            {
                foreach (int ContactID in new List <int>()
                {
                    AdminContactID
                })                                                             //, TestEmailValidatedContactID, TestEmailNotValidatedContactID })
                {
                    BoxModelController boxModelController = new BoxModelController(DatabaseTypeEnum.SqlServerTestDB);
                    Assert.IsNotNull(boxModelController);
                    Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, boxModelController.DatabaseType);

                    BoxModel boxModelFirst = new BoxModel();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        BoxModelService boxModelService = new BoxModelService(new Query(), db, ContactID);
                        boxModelFirst = (from c in db.BoxModels select c).FirstOrDefault();
                    }

                    // ok with BoxModel info
                    IHttpActionResult jsonRet = boxModelController.GetBoxModelWithID(boxModelFirst.BoxModelID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <BoxModel> Ret = jsonRet as OkNegotiatedContentResult <BoxModel>;
                    BoxModel boxModelRet = Ret.Content;
                    Assert.AreEqual(boxModelFirst.BoxModelID, boxModelRet.BoxModelID);

                    BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult;
                    Assert.IsNull(badRequest);

                    // Not Found
                    IHttpActionResult jsonRet2 = boxModelController.GetBoxModelWithID(0);
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <BoxModel> boxModelRet2 = jsonRet2 as OkNegotiatedContentResult <BoxModel>;
                    Assert.IsNull(boxModelRet2);

                    NotFoundResult notFoundRequest = jsonRet2 as NotFoundResult;
                    Assert.IsNotNull(notFoundRequest);
                }
            }
        }
Beispiel #32
0
        private void GetDataBox()
        {
            var DataBoxList = DataAccess.GetDataBox();

            foreach (var DataBox in DataBoxList)
            {
                var ItemInsert = new BoxModel()
                {
                    Id            = DataBox.Key,
                    NameParentBox = DataBox.Value[0],
                    NameBox       = DataBox.Value[1]
                };

                if (!homeModelsList.Contains(ItemInsert))
                {
                    homeModelsList.Add(ItemInsert);
                }
            }
        }