public InventoryBusinessModel GetInventoryById(int id) { var mapper = new InventoryMapper(); var inventory = this.uow.Inventories.GetById(id); return(mapper.Map(inventory)); }
public InventoryBusinessModel GetInventoryByNumber(string number) { var inventory = this.uow.Inventories.GetAll().SingleOrDefault(c => c.Number == number); var mapper = new InventoryMapper(); return(mapper.Map(inventory)); }
public List <InventoryBusinessModel> GetAllInventory() { var mapper = new InventoryMapper(); var inventory = this.uow.Inventories.GetAll().ToList().Select(mapper.Map).ToList(); return(inventory); }
public void CreateInventory(InventoryBusinessModel inventoryModel) { var mapper = new InventoryMapper(); this.uow.Inventories.Add(mapper.Map(inventoryModel)); this.uow.Commit(); }
public ServiceInventories.ProductInventory GetProductInventoryRecordByProductId(int id) { var entityProductInventory = _inventoriesReader.GetProductInventoryRecordFromDbByProductId(id); var serviceProductInventory = InventoryMapper.SerialiseProductInventoryRecord(entityProductInventory); return(serviceProductInventory); }
public void UpdateInventory(InventoryBusinessModel inventoryModel) { var mapper = new InventoryMapper(); Inventory inv = mapper.Map(inventoryModel); this.uow.Inventories.Update(inv); this.uow.Commit(); }
public IActionResult GetCurrentInventory() { _logger.LogInformation("Getting all inventory"); var inventory = _inventoryService.GetCurrentInventory(); var inventoryViewModels = InventoryMapper.SerializeInventory(inventory); return(Ok(inventoryViewModels)); }
public JsonResult GetAppointments(int restaurantId) { var inventories = _context.Inventories.Where(i => i.restaurant.Id == restaurantId).ToList(); var model = InventoryMapper.GetInventoriesModelFrom(inventories); return(Json(model)); }
public List<InventoryBusinessModel> GetAllInventoryByConsignmentId(int consignmentId) { InventoryMapper inventoryMapper = new InventoryMapper(); var inventories = this.uow.Inventories.GetAll() .Where(x => x.Consignment.Id == consignmentId).ToList() .Select(inventoryMapper.Map).ToList(); return inventories; }
/// <summary> /// Initializes the logger, inventory repository, inventory mapper, and loads in all the inventory data. /// </summary> /// <param name="logger"></param> /// <param name="repository"></param> /// <param name="mapper"></param> public MainViewModel(ILogger <MainViewModel> logger, IInventoryRepository repository, InventoryMapper mapper) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _repository = repository ?? throw new ArgumentNullException(nameof(repository)); _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); // Load in the repository _ = LoadAsync(); }
public List <InventoryBusinessModel> GetAllInventoryByConsignmentId(int consignmentId) { InventoryMapper inventoryMapper = new InventoryMapper(); var inventories = this.uow.Inventories.GetAll() .Where(x => x.Consignment.Id == consignmentId).ToList() .Select(inventoryMapper.Map).ToList(); return(inventories); }
public IEnumerable <ServiceInventories.ProductInventory> GetCurrentProductInventory() { var entityProductInventories = _inventoriesReader.GetCurrentProductInventoryFromDb(); var serviceProductInventories = entityProductInventories .Select(pi => InventoryMapper .SerialiseProductInventoryRecord(pi)); return(serviceProductInventories); }
public override async Task <List <Inventory> > AllAsync() { return(await RepositoryDbSet .Include(i => i.Description).ThenInclude(t => t.Translations) .Include(a => a.Shop).ThenInclude(aa => aa.ShopName).ThenInclude(t => t.Translations) .Include(a => a.Shop).ThenInclude(aa => aa.ShopAddress).ThenInclude(t => t.Translations) .Include(a => a.Shop).ThenInclude(aa => aa.ShopContact).ThenInclude(t => t.Translations) .Include(a => a.Shop).ThenInclude(aa => aa.ShopContact2).ThenInclude(t => t.Translations) .Select(e => InventoryMapper.MapFromDomain(e)).ToListAsync()); }
public IEnumerable <ServiceInventories.ProductInventorySnapshot> GetSnapshotHistory() { var oneWeekAgo = DateTime.Now.AddDays(-7); var entityPastWeeksSnapshotHistory = _inventoriesReader.GetSnapshotHistoryFromDb(oneWeekAgo); var servicePastWeeksSnapshotHistory = entityPastWeeksSnapshotHistory .Select(s => InventoryMapper .SerialiseProductInventorySnapshot(s)); return(servicePastWeeksSnapshotHistory); }
public void CreateInventoryTest() { var tempInventory = this.fixture.Create<Inventory>(); var mapper = new InventoryMapper(); this.inventoryFacade.CreateInventory(mapper.Map(tempInventory)); var result = inventoryFacade.GetInventoryById(tempInventory.InventoryId); Assert.AreEqual(tempInventory.InventoryId, result.InventoryId); Assert.AreEqual(tempInventory.Number, result.Number); Assert.AreEqual(tempInventory.IsAvailable, result.IsAvailable); Assert.AreEqual(tempInventory.WriteOffDate, result.WriteOffDate); }
public ActionResult GetInventories() { _logger.LogInformation("Getting inventories"); var inventory = _inventoryService.GetCurrentInventory(); var inventoryViewModel = inventory .Select(i => InventoryMapper.SerializeInventory(i)) .OrderBy(i => i.InventoryProduct.Name) .ToList(); return(Ok(inventoryViewModel)); }
public async Task <ActionResult <PublicApi.v1.DTO.InventoryWithProductCount> > GetInventory(int id) { var inventory = await _bll.Inventories.FindByShopAsyncAndIdAsync(id, User.GetShopId()); if (inventory == null) { return(NotFound()); } return(InventoryMapper.MapFromBLL(inventory)); }
public void InventoryModelToEntityMappingTest() { var inventoryModel = this.fixture.Create<InventoryBusinessModel>(); var inventoryMapper = new InventoryMapper(); var inventory = inventoryMapper.Map(inventoryModel); Assert.AreEqual(inventoryModel.InventoryId, inventory.InventoryId, "Id is not correct"); Assert.AreEqual(inventoryModel.IsAvailable, inventory.IsAvailable, "IsAvailable is not correct"); Assert.AreEqual(inventoryModel.Number, inventory.Number, "Number is not correct"); Assert.AreEqual(inventoryModel.WriteOffDate, inventory.WriteOffDate, "WriteOffDate is not correct"); Assert.AreEqual(inventoryModel.Item, inventory.Item, "Item is not correct"); }
public async Task <IActionResult> PutInventory(int id, PublicApi.v1.DTO.Inventory inventory) { if (!ModelState.IsValid || id != inventory.Id || inventory.ShopId != User.GetShopId()) { return(BadRequest()); } _bll.Inventories.Update(InventoryMapper.MapFromExternal(inventory)); await _bll.SaveChangesAsync(); return(NoContent()); }
public void UpdateInventoryTest() { var mapper = new InventoryMapper(); this.inventoryFacade.UpdateInventory(mapper.Map(this.testInventory)); var result = this.inventoryFacade.GetInventoryById(this.testInventory.InventoryId); Assert.AreEqual(this.testInventory.InventoryId, result.InventoryId); Assert.AreEqual(this.testInventory.Number, result.Number); Assert.AreEqual(this.testInventory.IsAvailable, result.IsAvailable); Assert.AreEqual(this.testInventory.WriteOffDate, result.WriteOffDate); }
public void InventoryModelToEntityMappingTest() { var inventoryModel = this.fixture.Create <InventoryBusinessModel>(); var inventoryMapper = new InventoryMapper(); var inventory = inventoryMapper.Map(inventoryModel); Assert.AreEqual(inventoryModel.InventoryId, inventory.InventoryId, "Id is not correct"); Assert.AreEqual(inventoryModel.IsAvailable, inventory.IsAvailable, "IsAvailable is not correct"); Assert.AreEqual(inventoryModel.Number, inventory.Number, "Number is not correct"); Assert.AreEqual(inventoryModel.WriteOffDate, inventory.WriteOffDate, "WriteOffDate is not correct"); Assert.AreEqual(inventoryModel.Item, inventory.Item, "Item is not correct"); }
public void CreateInventoryTest() { var tempInventory = this.fixture.Create <Inventory>(); var mapper = new InventoryMapper(); this.inventoryFacade.CreateInventory(mapper.Map(tempInventory)); var result = inventoryFacade.GetInventoryById(tempInventory.InventoryId); Assert.AreEqual(tempInventory.InventoryId, result.InventoryId); Assert.AreEqual(tempInventory.Number, result.Number); Assert.AreEqual(tempInventory.IsAvailable, result.IsAvailable); Assert.AreEqual(tempInventory.WriteOffDate, result.WriteOffDate); }
public override async Task <Inventory> FindAsync(params object[] id) { var inventory = await RepositoryDbSet.FindAsync(id); return(InventoryMapper.MapFromDomain(await RepositoryDbSet.Where(a => a.Id == inventory.Id) .Include(i => i.Description).ThenInclude(t => t.Translations) .Include(a => a.Products).ThenInclude(aa => aa.ProductName).ThenInclude(t => t.Translations) .Include(a => a.Products).ThenInclude(aa => aa.Length).ThenInclude(t => t.Translations) .Include(a => a.Products).ThenInclude(aa => aa.Weight).ThenInclude(t => t.Translations) .Include(a => a.Products).ThenInclude(aa => aa.ManuFacturerItemCode).ThenInclude(t => t.Translations) .Include(a => a.Products).ThenInclude(aa => aa.ShopCode).ThenInclude(t => t.Translations) .Include(a => a.Shop).ThenInclude(aa => aa.ShopName).ThenInclude(t => t.Translations) .Include(a => a.Shop).ThenInclude(aa => aa.ShopAddress).ThenInclude(t => t.Translations) .Include(a => a.Shop).ThenInclude(aa => aa.ShopContact).ThenInclude(t => t.Translations) .Include(a => a.Shop).ThenInclude(aa => aa.ShopContact2).ThenInclude(t => t.Translations) .FirstOrDefaultAsync())); }
public List <InventoryBusinessModel> GetAllInventory() { List <InventoryBusinessModel> inlist; using (LibraryUow uow = new LibraryUow()) { inlist = new List <InventoryBusinessModel>(); var inv = uow.Inventories.GetAll().ToList(); var invMapper = new InventoryMapper(); foreach (var a in inv) { inlist.Add(invMapper.Map(a)); } //var invBusinessModel = inv.Select(a => invMapper.Map(a)).ToList(); } return(inlist); }
public async Task <List <Inventory> > AllAsyncByShop(int?shopId, string order, string searchFor, int?pageIndex, int?pageSize) { var query = RepositoryDbSet .Include(i => i.Description).ThenInclude(t => t.Translations) .Include(a => a.Shop).ThenInclude(aa => aa.ShopName).ThenInclude(t => t.Translations) .Include(a => a.Shop).ThenInclude(aa => aa.ShopAddress).ThenInclude(t => t.Translations) .Include(a => a.Shop).ThenInclude(aa => aa.ShopContact).ThenInclude(t => t.Translations) .Include(a => a.Shop).ThenInclude(aa => aa.ShopContact2).ThenInclude(t => t.Translations) .Where(s => s.ShopId == shopId).AsQueryable(); query = Search(query, searchFor); query = Order(query, order); if (pageIndex != null && pageSize != null) { query = query.Skip((pageIndex.Value - 1) * pageSize.Value).Take(pageSize.Value); } var temp = await query.ToListAsync(); var res = temp.Select(e => InventoryMapper.MapFromDomain(e)).ToList(); return(res); }
// not a fan of the nested try/catch. Must be a better way public ServiceResponse <ServiceInventories.ProductInventory> UpdateQuantityAvailable(int productId, int adjustment) { var productInventory = _inventoriesReader.GetProductInventoryRecordFromDbByProductId(productId); var now = DateTime.Now; var response = new ServiceResponse <ServiceInventories.ProductInventory>() { Time = now }; try { _inventoriesWriter.UpdateQuantityAvailableInDb(productId, adjustment); try { productInventory.UpdatedOn = now; _inventoriesWriter.AddProductInventorySnapshotToDb(productInventory); } catch (Exception e) { _logger.LogError($"Failed to create product inventory snapshot for product inventory record {productInventory.Id} pertaining to product {productId}. " + $"Stack trace: {e.StackTrace}"); } response.IsSuccessful = true; response.Data = InventoryMapper.SerialiseProductInventoryRecord(productInventory); response.Message = $"Quantity successfully updated to {productInventory.QuantityAvailable} for product inventory record {productInventory.Id} pertaining to product {productId}"; } catch (Exception e) { response.IsSuccessful = false; response.Data = InventoryMapper.SerialiseProductInventoryRecord(productInventory); response.Message = $"Failed to update quanitity for product inventory record {productInventory.Id} pertaining to product {productId}. Stack trace: {e.StackTrace}"; } return(response); }
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; }
public InventoryBusinessModel GetInventoryById(int id) { var mapper = new InventoryMapper(); var inventory = this.uow.Inventories.GetById(id); return mapper.Map(inventory); }
public List<InventoryBusinessModel> GetAllInventory() { var mapper = new InventoryMapper(); var inventory = this.uow.Inventories.GetAll().ToList().Select(mapper.Map).ToList(); return inventory; }
public async Task <ActionResult <IEnumerable <PublicApi.v1.DTO.InventoryWithProductCount> > > GetInventory(string search, int?pageIndex, int?pageSize) { if ((pageIndex != null && pageIndex < 1) || (pageSize != null && pageSize < 1)) { return(BadRequest()); } var inventory = (await _bll.Inventories.GetByShopAsync(User.GetShopId(), search, pageIndex, pageSize)).Select(e => InventoryMapper.MapFromBLL(e)).ToList(); return(inventory); }
public async Task <List <Inventory> > AllAsync(string order, string searchFor, int?pageIndex, int?pageSize) { return((await Uow.Inventories.AllAsync(order, searchFor, pageIndex, pageSize)).Select(e => InventoryMapper.MapFromDAL(e)).ToList()); }
public async Task <InventoryWithProductCount> FindByShopAsyncAndIdAsync(int id, int?shopId) { return(InventoryMapper.MapFromDAL(await Uow.Inventories.FindByShopAsyncAndIdAsync(id, shopId))); }
public async Task <List <InventoryWithProductCount> > GetByShopAsync(int?shopId, string search, int?pageIndex, int?pageSize) { return((await Uow.Inventories.GetByShopAsync(shopId, search, pageIndex, pageSize)).Select(e => InventoryMapper.MapFromDAL(e)).ToList()); }
public override async Task <Inventory> FindAsync(params object[] id) { return(InventoryMapper.MapFromDAL(await Uow.Inventories.FindAsync(id))); }
public InventoryBusinessModel GetInventoryByNumber(string number) { var inventory = this.uow.Inventories.GetAll().SingleOrDefault(c => c.Number == number); var mapper = new InventoryMapper(); return mapper.Map(inventory); }
public override async Task <List <Inventory> > AllAsync() { return((await Uow.Inventories.AllAsync()).Select(e => InventoryMapper.MapFromDAL(e)).ToList()); }