示例#1
0
 /// <summary>
 /// Turn a location into an entity location
 /// </summary>
 /// <param name="location"></param>
 /// <returns></returns>
 public static Domain.Models.Location Map(Entities.LocationEntity location)
 {
     return(new Domain.Models.Location
     {
         ID = location.Id,
         LocationName = location.Name
     });
 }
示例#2
0
 /// <summary>
 /// Turn a location into an entity location
 /// </summary>
 /// <param name="location"></param>
 /// <returns></returns>
 public static Library.Models.Location Map(Entities.LocationEntity location)
 {
     return(new Library.Models.Location
     {
         ID = location.Id,
         LocationName = location.Name
     });
 }
示例#3
0
 /// <summary>
 /// turn an entity location with their inventory into a model inventory
 /// </summary>
 /// <param name="location"></param>
 /// <returns></returns>
 public static Library.Models.Location MapLocationsWithInventory(Entities.LocationEntity location)
 {
     return(new Library.Models.Location
     {
         ID = location.Id,
         LocationName = location.Name,
         Inventory = location.Inventories.Select(Mapper_Inventory.Map).ToList()
     });
 }
示例#4
0
 /// <summary>
 /// This turns a Location Entity into a Location model.
 /// </summary>
 /// <param name="customer">The customer entity.</param>
 /// <returns></returns>
 public static Library.Models.Location MapLocationWithOrders(Entities.LocationEntity location)
 {
     return(new Library.Models.Location
     {
         ID = location.Id,
         LocationName = location.Name,
         OrderHistory = location.Orders.Select(Mapper_Order.MapOrderWithOrderLines).ToList()
     });
 }
示例#5
0
        public static Location MapToLocation(Entities.LocationEntity dbLocation)
        {
            if (dbLocation == null)
            {
                return(null);
            }

            return(new Location
            {
                Id = dbLocation.Id,
                Name = dbLocation.Name,
                CreatedBy = dbLocation.CreatedBy,
                CreatedOn = dbLocation.CreatedOn,
                UpdatedBy = dbLocation.UpdatedBy,
                UpdatedOn = dbLocation.UpdatedOn,
            });
        }
示例#6
0
        public static Location MapToLocation(Entities.LocationEntity dbLocation)
        {
            if (dbLocation == null)
            {
                return(null);
            }

            return(new Location
            {
                Cidr = dbLocation.Cidr,
                Id = dbLocation.Id,
                Name = dbLocation.Name,
                Net = dbLocation.Net_Address_v4,
                CreatedBy = dbLocation.CreatedBy,
                CreatedOn = dbLocation.CreatedOn,
                UpdatedBy = dbLocation.UpdatedBy,
                UpdatedOn = dbLocation.UpdatedOn,
            });
        }
        /// <summary>
        /// The purpose is to turn the db information for a given locations order history into readable text.
        /// </summary>
        /// <param name="locationID"></param>
        /// <returns></returns>
        public IEnumerable <Domain.Models.Order> GetOrderHistoryByLocationID(int locationID)
        {
            // This method is called because we need the information on the whole catalog
            // Since the catalog is small I went with this implementation.
            // If it was much large I would only fill the Domain with the relevant books
            FillBookLibrary();

            // Find if the location exists and include all information including orders and their orderlines
            Entities.LocationEntity dbLocation = _context.Locations
                                                 .Include(o => o.Orders)
                                                 .ThenInclude(c => c.Orderlines)
                                                 .FirstOrDefault(l => l.Id == locationID);

            // If it doesn't exist then return that the location does not exist.
            if (dbLocation == null)
            {
                return(new List <Domain.Models.Order>());
            }
            return(dbLocation.Orders.Select(MapperOrder.MapOrderWithOrderLines));
        }