public static string AddInventoryEvent(InventoryEventDto inventoryEvent) { return($"INSERT INTO INVENTORY_EVENT(" + $"ID," + $"INVENTORY_ID," + $"EVENT_DATE," + $"DESCRIPTION," + $"EVENT_TYPE_ID)" + $"VALUES(" + $"null," + $"{inventoryEvent.InventoryId}," + $"'{inventoryEvent.EventDate.ToString("yyyy-MM-dd hh:mm:ss")}'," + $"'{inventoryEvent.Description}'," + $"{inventoryEvent.EventType})"); }
public void UpdateInventory(UpdateInventoryDto updateInventoryDto) { InventoryEventDto eventDto = null; try { var inventoryDto = _inventoryDao.GetInventoryById(updateInventoryDto.InventoryId); inventoryDto.StatusId = updateInventoryDto.NewStatusId; eventDto = new InventoryEventDto { Description = "Inventory action", EventDate = DateTime.Now, EventType = (int)InventoryEventTypeEnum.InventoryStarted, InventoryId = updateInventoryDto.InventoryId }; if (updateInventoryDto.NewStatusId == 3) { eventDto.EventType = (int)InventoryEventTypeEnum.InventoryEnded; CreateReport(updateInventoryDto.InventoryId); } else if (updateInventoryDto.NewStatusId == 4) { eventDto.EventType = (int)InventoryEventTypeEnum.InventoryCancelled; } _inventoryDao.UpdateInventory(inventoryDto); _inventoryDao.RemoveAllUsersFromInventory(inventoryDto.Id); } catch (Exception e) { eventDto = new InventoryEventDto { Description = e.Message, EventDate = DateTime.Now, InventoryId = 0, EventType = (int)InventoryEventTypeEnum.UnknownError }; } finally { _inventoryDao.AddInventoryEvent(eventDto); } }
public void CreateNewInventory(NewInventoryRequestDto newInventoryRequestDto) { InventoryEventDto eventDto = null; try { _inventoryDao.InsertInventory(new InventoryDto { Description = newInventoryRequestDto.Description, StartDate = DateTime.Now, StatusId = 1, ZoneId = newInventoryRequestDto.ZoneId }); eventDto = new InventoryEventDto { Description = "New inventory created", EventDate = DateTime.Now, EventType = (int)InventoryEventTypeEnum.InventoryCreated, InventoryId = 0 }; } catch (Exception e) { eventDto = new InventoryEventDto { Description = e.Message, EventDate = DateTime.Now, InventoryId = 0, EventType = (int)InventoryEventTypeEnum.UnknownError }; } finally { _inventoryDao.AddInventoryEvent(eventDto); } }
public void AddInventoryProduct(InventoryProduct inventoryProduct) { InventoryEventDto eventDto = null; try { var productDto = _productDao.GetProductById(inventoryProduct.ProductId); if (productDto == null) { eventDto = new InventoryEventDto { Description = $"Product {inventoryProduct.ProductId} does not exist in Product table", EventDate = DateTime.Now, InventoryId = inventoryProduct.InventoryId, EventType = (int)InventoryEventTypeEnum.NotExisitingProductScanned }; return; } var inventoryProductDto = _inventoryDao.GetInventoryProductByProductId(inventoryProduct.ProductId); if (inventoryProductDto != null) { eventDto = new InventoryEventDto { Description = $"Product {inventoryProduct.ProductId} was already scanned", EventDate = DateTime.Now, InventoryId = inventoryProduct.InventoryId, EventType = (int)InventoryEventTypeEnum.DuplicateScanned }; } else { _inventoryDao.AddInventoryProduct(inventoryProduct.ToDto()); eventDto = new InventoryEventDto { Description = $"Product {inventoryProduct.ProductId} was added into inventory {inventoryProduct.InventoryId}", EventDate = DateTime.Now, InventoryId = inventoryProduct.InventoryId, EventType = (int)InventoryEventTypeEnum.ProductAdded }; } } catch (Exception e) { eventDto = new InventoryEventDto { Description = e.Message, EventDate = DateTime.Now, InventoryId = inventoryProduct.InventoryId, EventType = (int)InventoryEventTypeEnum.UnknownError }; } finally { _inventoryDao.AddInventoryEvent(eventDto); } }
public void AddInventoryEvent(InventoryEventDto inventoryEvent) { NonResultQuerry(InventorySql.AddInventoryEvent(inventoryEvent)); }