コード例 #1
0
        Entity CreateASnake()
        {
            var snake      = _entityService.CreateEntity("snake").Result;
            var healthComp = _componentService.CreateComponent("health", "maxHp=150, currHp=95");

            snake.AddComponent(healthComp);

            return(snake);
        }
コード例 #2
0
        public async void CreateComponentTest()
        {
            Workspace workspace = await CreateWorkspace();

            Component componentTemplate = CreateComponentTemplate(workspace);
            Component component         = await service.CreateComponent(componentTemplate);

            Assert.NotNull(component.Id);
            await service.DeleteComponent(component.Id);

            await DeleteWorkspace(workspace);
        }
コード例 #3
0
        public async Task CreateComponentTest()
        {
            var workspace = await CreateWorkspace();

            var componentTemplate = CreateComponentTemplate(workspace);
            var component         = await _service.CreateComponent(componentTemplate);

            Assert.NotNull(component.Id);
            await _service.DeleteComponent(component.Id);

            await DeleteWorkspace(workspace);
        }
コード例 #4
0
        public ActionResult Setup(ComponentSetupViewModel vm)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (vm.Id > 0)
                    {
                        ViewBag.Title = ComponentStrings.Component_Edit_Title;

                        if (_componentService.UpdateComponent(vm))
                        {
                            SystemMessages.Add(ComponentStrings.Component_Update_Success_Msg, false, true);
                        }
                        else
                        {
                            SystemMessages.Add(CommonStrings.No_Record, true, true);
                        }
                    }
                    else
                    {
                        ViewBag.Title = ComponentStrings.Component_Create_Title;

                        _componentService.CreateComponent(vm);
                        SystemMessages.Add(ComponentStrings.Component_Create_Success_Msg, false, true);
                    }

                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    SystemMessages.Add(CommonStrings.Server_Error, true, true);
                }
            }

            ViewBag.ComponentTypeDropDown = new SelectList(_componentTypeService.GetComponentTypeDropDown(), "Value", "Text", vm.ComponentTypeId);
            ViewBag.DonorDropDown         = new SelectList(_donorService.GetDonorDropDown(), "Value", "Text", vm.DonorId);

            return(View("Setup", vm));
        }