Ejemplo n.º 1
0
        public DeptorsReadersModel Map(ReaderHistory o)
        {
            if (o == null)
            {
                return(null);
            }
            DeptorsReadersModel    deptorsReadersBusiness = new DeptorsReadersModel();
            ReaderMapper           readerMapper           = new ReaderMapper();
            InventoryMapper        inventoryMapper        = new InventoryMapper();
            ReaderBusinessModel    readerBusinessModel    = readerMapper.Map(o.Reader);
            InventoryBusinessModel invertoryBusinessModel = inventoryMapper.Map(o.Inventory);

            deptorsReadersBusiness.readerId  = readerBusinessModel.ReaderId;
            deptorsReadersBusiness.FirstName = readerBusinessModel.FirstName;
            deptorsReadersBusiness.LastName  = readerBusinessModel.LastName;
            deptorsReadersBusiness.Address   = readerBusinessModel.Address;
            deptorsReadersBusiness.Phone     = readerBusinessModel.Phone;
            if (o.Inventory != null)
            {
                deptorsReadersBusiness.ItemName = invertoryBusinessModel.Item.Name;
            }
            deptorsReadersBusiness.StartDate  = o.StartDate;
            deptorsReadersBusiness.FinishDate = o.FinishDate;

            return(deptorsReadersBusiness);
        }
Ejemplo n.º 2
0
        public BookBusinessModel Map(Book source)
        {
            if (source == null)
            {
                return(null);
            }

            var destination = new BookBusinessModel
            {
                Id        = source.Id,
                Name      = source.Name,
                Year      = source.Year,
                PageCount = source.PageCount,
                Publisher = source.Publisher,
            };


            if (source.Authors != null)
            {
                var authorMapper = new AuthorMapper();
                destination.Authors =
                    source.Authors.Select(
                        a => authorMapper.Map(new Author {
                    Id = a.Id, FirstName = a.FirstName, MiddleName = a.MiddleName, LastName = a.LastName
                }))
                    .ToList();
            }

            if (source.Inventories != null)
            {
                var inventoryMapper = new InventoryMapper();
                destination.Inventories =
                    source.Inventories.Select(
                        a =>
                        inventoryMapper.Map(new Inventory {
                    InventoryId = a.InventoryId, IsAvailable = a.IsAvailable
                }))
                    .ToList();
            }

            if (source.ReservedItems != null)
            {
                var reservedBookMapper = new ReservedItemMapper();
                destination.ReservedItems =
                    source.ReservedItems.Select(
                        a =>
                        reservedBookMapper.Map(new ReservedItem {
                    Item = null, Date = a.Date, Id = a.Id, Reader = a.Reader
                }))
                    .ToList();
            }

            destination.Tags = null;

            return(destination);
        }
Ejemplo n.º 3
0
        public HistoryBusinessModelForGrid Map(ReaderHistory o)
        {
            if (o == null)
            {
                return(null);
            }
            HistoryBusinessModelForGrid readerHistoryBusiness = new HistoryBusinessModelForGrid();
            ReaderMapper           readerMapper           = new ReaderMapper();
            InventoryMapper        inventoryMapper        = new InventoryMapper();
            ReaderBusinessModel    readerBusinessModel    = readerMapper.Map(o.Reader);
            InventoryBusinessModel invertoryBusinessModel = inventoryMapper.Map(o.Inventory);

            readerHistoryBusiness.ReaderName = readerBusinessModel.FirstName;
            readerHistoryBusiness.ItemName   = invertoryBusinessModel.Item.Name;
            readerHistoryBusiness.StartDate  = o.StartDate;
            readerHistoryBusiness.FinishDate = o.FinishDate;

            return(readerHistoryBusiness);
        }
Ejemplo n.º 4
0
        public ReaderHistory Map(ReaderHistoryBusinessModel o)
        {
            if (o == null)
            {
                return(null);
            }
            ReaderHistory   readerHistory   = new ReaderHistory();
            ReaderMapper    readerMapper    = new ReaderMapper();
            InventoryMapper inventoryMapper = new InventoryMapper();
            Reader          reader          = readerMapper.Map(o.ReaderBusiness);
            Inventory       invertory       = inventoryMapper.Map(o.InventoryBusiness);

            readerHistory.ReaderHistoryId = o.Id;
            readerHistory.StartDate       = o.StartDate;
            readerHistory.ReturnDate      = o.ReturnDate;
            readerHistory.FinishDate      = o.FinishDate;
            readerHistory.Reader          = reader;
            readerHistory.Inventory       = invertory;

            return(readerHistory);
        }
Ejemplo n.º 5
0
        public ReaderHistoryBusinessModel Map(ReaderHistory o)
        {
            if (o == null)
            {
                return(null);
            }
            ReaderHistoryBusinessModel readerHistoryBusiness = new ReaderHistoryBusinessModel();
            ReaderMapper           readerMapper           = new ReaderMapper();
            InventoryMapper        inventoryMapper        = new InventoryMapper();
            ReaderBusinessModel    readerBusinessModel    = readerMapper.Map(o.Reader);
            InventoryBusinessModel invertoryBusinessModel = inventoryMapper.Map(o.Inventory);

            readerHistoryBusiness.Id                = o.ReaderHistoryId;
            readerHistoryBusiness.StartDate         = o.StartDate;
            readerHistoryBusiness.ReturnDate        = o.ReturnDate;
            readerHistoryBusiness.FinishDate        = o.FinishDate;
            readerHistoryBusiness.ReaderBusiness    = readerBusinessModel;
            readerHistoryBusiness.InventoryBusiness = invertoryBusinessModel;

            return(readerHistoryBusiness);
        }
Ejemplo n.º 6
0
        public ConsignmentBusinessModel Map(Consignment source)
        {
            if (source == null)
            {
                return(null);
            }

            ConsignmentBusinessModel consignment = new ConsignmentBusinessModel
            {
                Id           = source.Id,
                Number       = source.Number,
                ArrivalDate  = source.ArrivalDate,
                WriteOffDate = source.WriteOffDate
            };

            if (source.Inventories != null)
            {
                var inventoryMapper = new InventoryMapper();
                consignment.Inventories =
                    source.Inventories.Select(
                        a =>
                        inventoryMapper.Map(
                            new Inventory
                {
                    InventoryId  = a.InventoryId,
                    IsAvailable  = a.IsAvailable,
                    Number       = a.Number,
                    WriteOffDate = a.WriteOffDate
                })).ToList();
            }
            if (source.Item != null)
            {
                var itemMapper = new ItemMapper();
                consignment.Item = itemMapper.Map(source.Item);
            }

            return(consignment);
        }