public Task <CreateAssetResponse> Handle(CreateAssetRequest request, CancellationToken cancellationToken)
        {
            var newAsset = new Entities.Asset(request.CreateAsset)
            {
                DrawingNo      = request.CreateAsset.DrawingNo,
                SerialNumber   = request.CreateAsset.SerialNumber,
                OperationHours = request.CreateAsset.OperationHours
            };

            if (request.CreateAsset.Features.Any())
            {
                var features = request.CreateAsset.Features.ToList();
                for (var i = 0; i < features.Count; i++)
                {
                    var newFeature = new AssetFeature(i, features[i]);
                    newAsset.AddFeature(newFeature);
                }
            }

            if (!string.IsNullOrEmpty(request.CreateAsset.InventoryNo))
            {
                var newInventory = new Inventory(request.CreateAsset.InventoryNo);
                newAsset.AddInventory(newInventory);
            }

            if (request.CreateAsset.AssetLocation != null)
            {
                var location    = request.CreateAsset.AssetLocation;
                var newLocation = new AssetLocation(newAsset.Id, location.LocatingTime, new Point(location.Longitude, location.Latitude), location.ClientOSInfo, location.ClientBrowserInfo, location.IsCreatedManually);
                newAsset.AddLocation(newLocation);
            }

            return(HandleIntern(newAsset, cancellationToken));
        }
Esempio n. 2
0
        public ActionResult Edit(AssetVM viewModel)
        {
            try
            {
                // TODO: Add update logic here
                if (ModelState.IsValid)
                {
                    Entities.Asset entity = new Entities.Asset();
                    entity.SrNo          = viewModel.SrNo;
                    entity.AssetName     = viewModel.AssetName;
                    entity.TypeofAsset   = viewModel.TypeofAsset;
                    entity.Quantity      = viewModel.Quantity;
                    entity.PricePerItem  = viewModel.PricePerItem;
                    entity.Total         = viewModel.Total;
                    entity.PurchaseDate  = viewModel.PurchaseDate;
                    entity.Condition     = viewModel.Condition;
                    entity.AssesmentYear = viewModel.AssesmentYear;
                    entity.Status        = viewModel.Status;
                    entity.Remark        = viewModel.Remark;
                    AssetBAL balObject = new AssetBAL();
                    balObject.Edit(entity);
                    TempData["Message"] = "Asset entry updated successfully !!!";
                }
                else
                {
                    TempData["Error"] = "Some problem while updating asset entry !!!";
                }
            }
            catch
            {
                TempData["Error"] = "Some problem while updating asset entry !!!";
            }

            return(View(viewModel));
        }
        private async Task <CreateAssetResponse> HandleIntern(Entities.Asset asset, CancellationToken cancellationToken)
        {
            _context.Assets.Add(asset);
            await _context.SaveChangesAsync(cancellationToken);

            return(new CreateAssetResponse
            {
                Success = true,
                AssetCreated = asset
            });
        }
Esempio n. 4
0
        /// <summary>
        /// Creates or updates a <see cref="Asset"/>. Both tasks use the same method due to the
        /// way Shopify API handles assets. If an asset has a unique <see cref="Asset.Key"/> value,
        /// it will be created. If not, it will be updated. Copy an asset by setting the
        /// <see cref="Asset.SourceKey"/> to the target's <see cref="Asset.Key"/> value.
        /// Note: This will not return the asset's <see cref="Asset.Value"/> property. You should
        /// use <see cref="GetAsync(long, string, string)"/> to refresh the value after creating or updating.
        /// </summary>
        /// <param name="themeId">The id of the theme that the asset belongs to.</param>
        /// <param name="asset">The asset.</param>
        /// <param name="cancellationToken">Cancellation Token</param>
        /// <returns>The created or updated asset.</returns>
        public virtual async Task <Entities.Asset> CreateOrUpdateAsync(long themeId, Entities.Asset asset, CancellationToken cancellationToken = default)
        {
            var req     = PrepareRequest($"themes/{themeId}/assets.json");
            var content = new JsonContent(new
            {
                asset = asset
            });

            var response = await ExecuteRequestAsync <Entities.Asset>(req, HttpMethod.Put, cancellationToken, content, "asset");

            return(response.Result);
        }
Esempio n. 5
0
        public ActionResult Edit(int id)
        {
            AssetVM  viewModel = new AssetVM();
            AssetBAL balObject = new AssetBAL();
            IQueryable <Entities.Asset> entites = balObject.FindBy(a => a.SrNo == id);

            if (entites != null && entites.Count() > 0)
            {
                Entities.Asset entity = entites.FirstOrDefault();
                viewModel.SrNo          = entity.SrNo;
                viewModel.AssetName     = entity.AssetName;
                viewModel.TypeofAsset   = entity.TypeofAsset;
                viewModel.Quantity      = entity.Quantity;
                viewModel.PricePerItem  = entity.PricePerItem;
                viewModel.Total         = entity.Total;
                viewModel.PurchaseDate  = entity.PurchaseDate;
                viewModel.Condition     = entity.Condition;
                viewModel.AssesmentYear = entity.AssesmentYear;
                viewModel.Status        = entity.Status;
                viewModel.Remark        = entity.Remark;
            }
            return(View(viewModel));
        }