示例#1
0
        public async Task <IActionResult> Details(int itemId)
        {
            if (itemId <= 0)
            {
                return(BadRequest());
            }

            var itemInDb = await this.itemService
                           .GetByIdAsync(itemId);

            var detailsVM = new ItemDetailsVM
            {
                Id             = itemInDb.Id,
                Title          = itemInDb.Title,
                Description    = itemInDb.Description,
                Type           = itemInDb.Type,
                CommercialType = itemInDb.CommercialType,
                Size           = itemInDb.Size,
                Price          = itemInDb.Price,
                Quantity       = itemInDb.Quantity,
                Images         = itemInDb.Images
                                 .Select(im => new ImageVM
                {
                    Id     = im.Id,
                    Url    = im.Url,
                    ItemId = itemInDb.Id
                }).ToList(),
                IsAvailable = itemInDb.IsAvailable
            };

            return(View(detailsVM));
        }
示例#2
0
        internal ItemDetailsVM MapItemDetails(Item item)
        {
            var itemVM = new ItemDetailsVM()
            {
                Id                       = item.Id,
                CreatedById              = item.CreatedById,
                CreatedDateTime          = item.CreatedDateTime,
                ModifiedById             = item.ModifiedById,
                ModifiedDateTime         = item.ModifiedDateTime,
                CatalogNumber            = item.CatalogNumber,
                Description              = item.Description,
                DrawingNumber            = item.DrawingNumber,
                Thumbnail                = item.Thumbnail,
                ImageData                = "",
                LowQuantityValue         = item.LowQuantityValue,
                Name                     = item.Name,
                Quantity                 = item.Quantity,
                SupplierName             = item.Supplier.Name,
                SupplierId               = item.Supplier.Id,
                StructuresForItemDetails = new List <StructuresForItemDetails>(),
                CheckIns                 = new List <CheckInsForItemDetails>(),
                CheckOuts                = new List <CheckOutsForItemDetails>()
            };

            if (item.Thumbnail != null)
            {
                itemVM.ImageData = CreateImgData(item.Thumbnail);
            }

            foreach (var s in item.ItemStructures)
            {
                itemVM.StructuresForItemDetails.Add(new StructuresForItemDetails()
                {
                    StructureId          = s.StructureId,
                    QuantityForStructure = s.ItemQuantity,
                    StructureName        = s.Structure.Name
                });
            }

            foreach (var c in item.CheckIns)
            {
                itemVM.CheckIns.Add(new CheckInsForItemDetails()
                {
                    ActionDateTime = c.ModifiedDateTime,
                    CheckInId      = c.Id,
                    Quantity       = c.Quantity,
                    UserName       = c.ModifiedById
                });
            }

            foreach (var c in item.CheckOuts)
            {
                itemVM.CheckOuts.Add(new CheckOutsForItemDetails()
                {
                    ActionDateTime = c.ModifiedDateTime,
                    CheckOutId     = c.Id,
                    Quantity       = c.Quantity,
                    UserName       = c.ModifiedById
                });
            }
            return(itemVM);
        }