예제 #1
0
        public async Task <AssetViewModel> UpdateAsync(Guid userId, Guid id, AssetUpdateModel model)
        {
            Asset asset = await _assetRepository.GetByIdAsync(userId, id);

            if (asset == null)
            {
                throw new Exception($"Asset {id} not found!");
            }

            bool balanceExists = await _balanceRepository.ExistsAssetBalanceAsync(userId, id);

            if (balanceExists && !asset.Balance.Currency.Equals(model.Currency, StringComparison.OrdinalIgnoreCase))
            {
                throw new Exception($"Can't update currency of the Asset {id} if Asset's Balance exists!");
            }

            Money money  = new Money(model.Value, model.Currency);
            Asset result = await _assetRepository.UpdateAsync(userId, id, model.Name, money, model.IsActive, DateTime.UtcNow);

            await _unitOfWork.SaveChangesAsync();

            AssetViewModel viewModel = new AssetViewModel(result);

            return(viewModel);
        }
예제 #2
0
        public ActionResult EditRecord(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Guid deleteGuid = new Guid();

            Guid.TryParse(id, out deleteGuid);

            AccountBook accountBook = db.AccountBook.Find(deleteGuid);

            if (accountBook == null)
            {
                return(HttpNotFound());
            }

            AssetViewModel avm = new AssetViewModel();

            avm.Category    = accountBook.Categoryyy;
            avm.Money       = accountBook.Amounttt;
            avm.Date        = accountBook.Dateee;
            avm.Description = accountBook.Remarkkk;

            return(View(avm));
        }
예제 #3
0
        private async Task UpdateNavigationMeshLink(AssetViewModel asset)
        {
            if (!navigationMeshAssets.ContainsKey(asset.Id))
            {
                navigationMeshAssets.Add(asset.Id, asset);
            }

            // Either add or remove the navigation mesh to the navigation mesh manager, which will then handle loading the
            //   navigation mesh whenever it gets compiled and then call NavigationMeshManagerOnChanged to update the
            //   shown navigation mesh
            var navigationMeshAsset = (NavigationMeshAsset)asset.Asset;

            if (ShouldDisplayNavigationMesh(navigationMeshAsset))
            {
                await navigationMeshManager.AddUnique(asset.Id);
            }
            else
            {
                if (navigationMeshManager.Meshes.TryGetValue(asset.Id, out NavigationMesh navigationMesh))
                {
                    await navigationMeshManager.Remove(asset.Id);

                    RemoveNavigationMesh(navigationMesh);
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EditorNavigationViewModel"/> class.
        /// </summary>
        /// <param name="editor"></param>
        /// <param name="serviceProvider">The service provider for this view model.</param>
        /// <param name="controller">The controller object for the related editor game.</param>
        public EditorNavigationViewModel([NotNull] IViewModelServiceProvider serviceProvider, [NotNull] IEditorGameController controller, [NotNull] EntityHierarchyEditorViewModel editor)
            : base(serviceProvider)
        {
            if (controller == null)
            {
                throw new ArgumentNullException(nameof(controller));
            }
            this.editor     = editor;
            this.controller = controller;

            ToggleAllGroupsCommand = new AnonymousCommand <bool>(ServiceProvider, value => Visuals.ForEach(x => x.IsVisible = value));

            gameSettingsAsset = editor.Session.AllAssets.FirstOrDefault(x => x.AssetType == typeof(GameSettingsAsset));
            if (gameSettingsAsset != null)
            {
                gameSettingsAsset.PropertyGraph.ItemChanged += GameSettingsPropertyGraphOnItemChanged;
                gameSettingsAsset.PropertyGraph.Changed     += GameSettingsPropertyGraphOnChanged;
                UpdateNavigationMeshLayers();
            }

            editor.Dispatcher.InvokeTask(async() =>
            {
                await controller.GameContentLoaded;
                service = controller.GetService <EditorGameNavigationMeshService>();
                UpdateNavigationMeshLayers();
            });
        }
예제 #5
0
        /// <inheritdoc/>
        public async Task <IAssetEditorViewModel> InitializeEditor(AssetViewModel asset)
        {
            var script = (ScriptSourceFileAssetViewModel)asset;

            editor = new ScriptEditorViewModel(script, script.TextContainer);

            // Ctrl + mouse wheel => zoom/unzoom
            CodeEditor.PreviewMouseWheel += OnEditorMouseWheel;

            editor.DocumentClosed     += Editor_DocumentClosed;
            editor.ProcessDiagnostics += Editor_ProcessDiagnostics;

            // Don't set the actual Editor property until the editor object is fully initialized - we don't want data bindings to access uninitialized properties
            var result = await editor.Initialize();

            // Bind SourceTextContainer to UI
            CodeEditor.BindSourceTextContainer(editor.Workspace, script.TextContainer, editor.DocumentId);

            editorInitializationNotifier.SetResult(result);
            if (result)
            {
                return(editor);
            }

            editor.Destroy();
            return(null);
        }
예제 #6
0
        public List <AssetViewModel> SearchAsset(AssetViewModel obj)
        {
            List <AssetViewModel> result = new List <AssetViewModel>();

            if (obj != null)
            {
                var asset = _asset.SearchAsset(obj.CategoryCD, obj.Ismovable, obj.Owner);
                foreach (var item in asset)
                {
                    AssetViewModel model          = new AssetViewModel();
                    var            categoryCDName = _pref.GetLookupByCategoryCode(item.CategoryCD);
                    var            statusCDName   = _pref.GetLookupByStatusCode(item.StatusCD);

                    model.ID                   = item.ID;
                    model.Code                 = item.Code;
                    model.Description          = item.Description;
                    model.No                   = item.No;
                    model.Name                 = item.Name;
                    model.IsMovable            = item.IsMovable;
                    model.Owner                = item.Owner;
                    model.PurchaseDate         = item.PurchaseDate;
                    model.PurchasePrice        = item.PurchasePrice;
                    model.DepreciationDuration = item.DepreciationDuration;
                    model.DisposedDate         = item.DisposedDate;
                    model.ManufactureDate      = item.ManufactureDate;
                    model.CategoryCD           = item.CategoryCD;
                    model.CategoryCDName       = categoryCDName.Value;
                    model.StatusCD             = item.StatusCD;
                    model.StatusCDName         = statusCDName.Value;

                    result.Add(model);
                }
            }
            return(result);
        }
예제 #7
0
        public async Task <ActionResult> DeleteAsset(Guid AssetID)
        {
            var asset = new Asset {
                AssetID = AssetID
            };

            DbContext.Assets.Attach(asset);
            DbContext.Assets.Remove(asset);

            var   task = DbContext.SaveChangesAsync();
            await task;

            if (task.Exception != null)
            {
                ModelState.AddModelError("", "Unable to Delete the Asset");
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                AssetViewModel assetVM = MapToViewModel(asset);
                return(View(Request.IsAjaxRequest() ? "_DeletePartial" : "Delete", assetVM));
            }

            if (Request.IsAjaxRequest())
            {
                return(Content("success"));
            }

            return(RedirectToAction("Index"));
        }
예제 #8
0
        public async Task <JsonResult> Create(AssetViewModel model)
        {
            try
            {
                //CreateHttpContent<T>(content)

                var response = await ApiClientFactory.Instance.SaveAsset(model);

                //var respond = await client.PostAsync("PostAsset", CreateHttpContent model);

                //if (respond.IsSuccessStatusCode)
                //{
                //    assets = await respond.Content.ReadAsAsync<IList<AssetViewModel>>();
                //}
                //else
                //{
                //    assets = Enumerable.Empty<AssetViewModel>();
                //    ModelState.AddModelError(string.Empty, "Server error. Please contact ICT");
                //}
                return(Json(response));
            }
            catch
            {
                throw new Exception("Something is wrong");
            }
        }
예제 #9
0
        public HttpResponseMessage SearchAsset(HttpRequestMessage request, [FromBody] AssetViewModel obj)
        {
            HttpResponseMessage response = new HttpResponseMessage();

            response = _assetProcess.SearchAsset(obj);
            return(response);
        }
예제 #10
0
        public async Task <ActionResult> Edit(AssetViewModel assetVM)
        {
            assetVM.FacilitySitesSelectList = GetFacilitiySitesSelectList(assetVM.FacilitySiteID);
            if (!ModelState.IsValid)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(View(Request.IsAjaxRequest() ? "_EditPartial" : "Edit", assetVM));
            }

            Asset asset = MaptoModel(assetVM);

            DbContext.Assets.Attach(asset);
            DbContext.Entry(asset).State = EntityState.Modified;
            var   task = DbContext.SaveChangesAsync();
            await task;

            if (task.Exception != null)
            {
                ModelState.AddModelError("", "Unable to update the Asset");
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(View(Request.IsAjaxRequest() ? "_EditPartial" : "Edit", assetVM));
            }

            if (Request.IsAjaxRequest())
            {
                return(Content("success"));
            }

            return(RedirectToAction("Index"));
        }
예제 #11
0
        public HttpResponseMessage AssetMovementHistory(HttpRequestMessage request, [FromBody] AssetViewModel obj)
        {
            HttpResponseMessage response = new HttpResponseMessage();

            response = _assetProcess.AssetMovementHistory(obj);
            return(response);
        }
예제 #12
0
        public HttpResponseMessage download(HttpRequestMessage request, [FromBody] AssetViewModel obj)
        {
            HttpResponseMessage response = new HttpResponseMessage();

            response = _assetProcess.download(obj);
            return(response);
        }
예제 #13
0
        // GET: Assets/Create
        public ActionResult Create()
        {
            AssetViewModel createAssetViewModel = new AssetViewModel();

            PopulateSelectLists(createAssetViewModel);
            return(View(createAssetViewModel));
        }
예제 #14
0
        private async Task <List <BalanceViewModel> > AddBalancesByTemplateAsync(Guid userId, DateTime latestEffectiveDate, DateTime effectiveDate)
        {
            IEnumerable <Balance> latestBalances = await _balanceRepository.GetByEffectiveDateAsync(userId, latestEffectiveDate);

            IList <AssetBankAccount> bankAccounts = await _assetBankAccountRepository.GetByUserIdAsync(userId);

            List <BalanceViewModel> result = new List <BalanceViewModel>();

            foreach (Balance balance in latestBalances)
            {
                decimal value = balance.Value;

                if (bankAccounts.Any(ba => ba.AssetId == balance.AssetId))
                {
                    BankAccountBalance bankAccountBalance = await _bankAccountService.GetBankAccountBalanceAsync(userId, balance.AssetId);

                    if (bankAccountBalance != null)
                    {
                        value = bankAccountBalance.Balance;
                    }
                }

                Balance newBalance = await _balanceRepository.CreateAsync(userId, balance.AssetId, effectiveDate, value);

                var assetModel = new AssetViewModel(balance.Asset);
                var model      = new BalanceViewModel(newBalance, assetModel);
                result.Add(model);
            }

            await _unitOfWork.SaveChangesAsync();

            return(result);
        }
예제 #15
0
        private Asset MaptoModel(AssetViewModel assetVM)
        {
            Asset asset = new Asset()
            {
                AssetID                   = assetVM.AssetID,
                Barcode                   = assetVM.Barcode,
                AstID                     = assetVM.AstID,
                Building                  = assetVM.Building,
                ChildAsset                = assetVM.ChildAsset,
                Comments                  = assetVM.Comments,
                Corridor                  = assetVM.Corridor,
                EquipSystem               = assetVM.EquipSystem,
                FacilitySiteID            = assetVM.FacilitySiteID,
                Floor                     = assetVM.Floor,
                GeneralAssetDescription   = assetVM.GeneralAssetDescription,
                Issued                    = assetVM.Issued,
                Manufacturer              = assetVM.Manufacturer,
                MERNo                     = assetVM.MERNo,
                ModelNumber               = assetVM.ModelNumber,
                PMGuide                   = assetVM.PMGuide,
                Quantity                  = assetVM.Quantity,
                RoomNo                    = assetVM.RoomNo,
                SecondaryAssetDescription = assetVM.SecondaryAssetDescription,
                SerialNumber              = assetVM.SerialNumber
            };

            return(asset);
        }
예제 #16
0
        private void GridMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (Session == null)
            {
                return;
            }

            var logMessage = logGridView.SelectedItem as AssetSerializableLogMessage;

            if (logMessage != null && !string.IsNullOrEmpty(logMessage.AssetUrl))
            {
                var asset = Session.GetAssetById(logMessage.AssetId);
                if (asset != null)
                {
                    Session.ActiveAssetView.SelectAssetCommand.Execute(asset);
                }
            }

            var assetLogMessage = logGridView.SelectedItem as AssetLogMessage;

            if (assetLogMessage != null && assetLogMessage.AssetReference != null)
            {
                AssetViewModel asset = Session.GetAssetById(assetLogMessage.AssetReference.Id);
                if (asset != null)
                {
                    Session.ActiveAssetView.SelectAssetCommand.Execute(asset);
                }
            }
        }
예제 #17
0
        // GET: Asset/Create
        public ActionResult Create()
        {
            var model = new AssetViewModel();

            model.FacilitySitesSelectList = GetFacilitiySitesSelectList();
            return(View("_CreatePartial", model));
        }
예제 #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GameEditorViewModel"/> class.
 /// </summary>
 /// <param name="asset">The asset related to this editor.</param>
 /// <param name="controllerFactory">A factory to create the associated <see cref="IEditorGameController"/>.</param>
 protected GameEditorViewModel([NotNull] AssetViewModel asset, [NotNull] Func <GameEditorViewModel, IEditorGameController> controllerFactory)
     : base(asset)
 {
     Controller = controllerFactory(this);
     CopyErrorToClipboardCommand = new AnonymousCommand(ServiceProvider, CopyErrorToClipboard);
     ResumeCommand = new AnonymousCommand(ServiceProvider, Resume);
 }
예제 #19
0
        public void Dispose()
        {
            if (!IsDisposed)
            {
                // Terminate preview control thread
                previewBuildQueue = null;

                session.AssetPropertiesChanged           -= OnAssetPropertyChanged;
                gameSettingsProvider.GameSettingsChanged -= OnGameSettingsChanged;

                if (PreviewGame.IsRunning)
                {
                    PreviewGame.Exit();
                }

                // Wait for the game thread to terminate
                previewGameThread.Join();


                //Game = null;
                host.Dispose();
                //host = null;
                //gameForm = null;
                //windowHandle = IntPtr.Zero;
                previewCompileContext?.Dispose();

                EditorDebugTools.UnregisterDebugPage(loggerDebugPage);

                IsDisposed = true;
            }
        }
예제 #20
0
        public AssetViewModel GetAssetByCode(string barcode)
        {
            AssetViewModel result = new AssetViewModel();

            var asset          = _asset.GetAssetInfoByCode(barcode);
            var categoryCDName = _pref.GetLookupByCategoryCode(asset.CategoryCD);
            var statusCDName   = _pref.GetLookupByStatusCode(asset.StatusCD);

            result.Code                 = asset.Code;
            result.Description          = asset.Description;
            result.No                   = asset.No;
            result.Name                 = asset.Name;
            result.IsMovable            = asset.IsMovable;
            result.Owner                = asset.Owner;
            result.PurchaseDate         = asset.PurchaseDate;
            result.PurchasePrice        = asset.PurchasePrice;
            result.DepreciationDuration = asset.DepreciationDuration;
            result.DisposedDate         = asset.DisposedDate;
            result.ManufactureDate      = asset.ManufactureDate;
            result.CategoryCD           = asset.CategoryCD;
            result.CategoryCDName       = categoryCDName.Value;
            result.StatusCD             = asset.StatusCD;
            result.StatusCDName         = statusCDName.Value;
            return(result);
        }
예제 #21
0
        /// <inheritdoc/>
        protected override IEntityPickerDialog CreatePicker(AssetViewModel asset, Type targetType)
        {
            var pickerDialog = Session.ServiceProvider.Get <IStrideDialogService>().CreateEntityComponentPickerDialog((EntityHierarchyEditorViewModel)asset.Editor, targetType);

            pickerDialog.Filter = item => item is EntityHierarchyRootViewModel || item.Asset == asset;
            return(pickerDialog);
        }
예제 #22
0
        public Editor(PackFileService pfs, SkeletonAnimationLookUpHelper skeletonAnimationLookUpHelper, AssetViewModel rider, AssetViewModel mount, AssetViewModel newAnimation, IComponentManager componentManager)
        {
            _pfs              = pfs;
            _newAnimation     = newAnimation;
            _mount            = mount;
            _rider            = rider;
            _selectionManager = componentManager.GetComponent <SelectionManager>();

            DisplayGeneratedSkeleton = new NotifyAttr <bool>(true, (value) => _newAnimation.IsSkeletonVisible = value);
            DisplayGeneratedMesh     = new NotifyAttr <bool>(true, (value) => { if (_newAnimation.MainNode != null)
                                                                                {
                                                                                    _newAnimation.MainNode.IsVisible = value;
                                                                                }
                                                             });

            SelectedRiderBone   = new FilterCollection <SkeletonBoneNode>(null, (x) => UpdateCanSaveAndPreviewStates());
            MountLinkController = new MountLinkController(pfs, skeletonAnimationLookUpHelper, rider, mount, UpdateCanSaveAndPreviewStates);

            ActiveOutputFragment = new FilterCollection <AnimationFragment>(null, OutputFragmentSelected);
            ActiveOutputFragment.SearchFilter = (value, rx) => { return(rx.Match(value.FileName).Success); };

            ActiveFragmentSlot = new FilterCollection <FragmentStatusSlotItem>(null, (x) => UpdateCanSaveAndPreviewStates());
            ActiveFragmentSlot.SearchFilter = (value, rx) => { return(rx.Match(value.Entry.Value.Slot.Value).Success); };

            _mount.SkeletonChanged  += MountSkeletonChanged;
            _rider.SkeletonChanged  += RiderSkeletonChanges;
            _rider.AnimationChanged += RiderAnimationChanged;

            MountSkeletonChanged(_mount.Skeleton);
            RiderSkeletonChanges(_rider.Skeleton);
        }
예제 #23
0
        /// <summary>
        /// Update an entity.
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public AssetViewModel Update(AssetViewModel model)
        {
            this.ThrowExceptionIfExist(model);

            var entity = this._AssetsRepository.Get(model.Id);

            // add Effiency Raise
            if (model.RaiseAmount != null)
            {
                var EffiencyRaise = new EffiencyRaiseHistoryViewModel();
                EffiencyRaise.RaiseAmount = model.RaiseAmount;
                EffiencyRaise.RaiseDate   = model.RaiseDate;

                this._EffiencyRaiseHistoryService.Add(EffiencyRaise);

                entity.DepreciationValue += model.RaiseAmount;
            }

            //entity.LocationId = model.LocationId;
            //entity.AccountChartId = model.AccountChartId;

            entity.Color      = model.Color;
            entity.Size       = model.Size;
            entity.Status     = model.Status;
            entity.Serial     = model.Serial;
            entity.Model      = model.Model;
            entity.Properties = model.Properties;

            entity = this._AssetsRepository.Update(entity);

            ConditionFilter <Asset, long> conditionFilter = new ConditionFilter <Asset, long>()
            {
                Query = (x =>
                         x.ParentKeyAssetId == entity.Id)
            };
            var childs = this._AssetsRepository.Get(conditionFilter);

            if (childs.Count() > 0)
            {
                var ar = childs.FirstOrDefault(x => x.Language == Language.Arabic);
                //ar.Name = model.NameAr;
                ar.Description = model.DescriptionAr;
                this._AssetsRepository.Update(ar);

                var en = childs.FirstOrDefault(x => x.Language == Language.English);
                //en.Name = model.NameEn;
                en.Description = model.DescriptionEn;
                this._AssetsRepository.Update(en);
            }



            #region Commit Changes
            this._unitOfWork.Commit();
            #endregion

            model = entity.ToModel();
            return(model);
        }
예제 #24
0
 public void SetAssetToPreview(AssetViewModel asset)
 {
     lock (previewLock)
     {
         previewBuildQueue = asset;
     }
     PreviewGame.Script.AddTask(ChangePreviewAsset);
 }
예제 #25
0
        public AssetHistoryViewModel AssetMovementHistory(AssetViewModel obj)
        {
            var result = new AssetHistoryViewModel();

            result.Asset   = _asset.GetAssetInfoByID(obj.Asset.ID);
            result.History = _movementRequest.AssetHistory_SP(obj.Asset.ID, obj.Skip);
            return(result);
        }
예제 #26
0
        public HttpResponseMessage MoveAsset(HttpRequestMessage request, [FromBody] AssetViewModel obj)
        {
            var result = service.MoveAsset(obj);
            HttpResponseMessage response = new HttpResponseMessage();

            response = request.CreateResponse(HttpStatusCode.OK, new { success = result });
            return(response);
        }
예제 #27
0
        public HttpResponseMessage MoveAsset(AssetViewModel obj)
        {
            HttpResponseMessage result = default(HttpResponseMessage);
            string requestUri          = "api/AssetLocation/MoveAsset";

            result = REST(requestUri, RESTConstants.POST, JsonConvert.SerializeObject(obj));
            return(result);
        }
예제 #28
0
        public async Task ThenBalanceEffectiveDateIsToday(string assetName)
        {
            DateTime       today = DateTime.UtcNow.Date;
            AssetViewModel asset = await _assetFeatureContext.AssetService.GetAssetByNameAsync(_userContext.UserId, assetName);

            _createdBalance.AssetId.Should().Be(asset.Id);
            _createdBalance.EffectiveDate.Should().Be(today);
        }
예제 #29
0
 public override void UpdateAsset(AssetViewModel asset)
 {
     asset.AddCSSPath("~/Content/objects/cardView.css");
     if (PaginationViewModel != null && !PaginationViewModel.IsSuppressed)
     {
         asset.AddCSSPath("~/Content/objects/pagination.css");
     }
 }
예제 #30
0
 public BalanceViewModel(Balance balance, AssetViewModel asset)
 {
     Id            = balance.Id;
     AssetId       = balance.AssetId;
     EffectiveDate = balance.EffectiveDate;
     Value         = balance.Value;
     Asset         = asset;
 }