public int ItemOutOfStock(ItemStockMessage stock) { RestaurantMenu menuObj = new RestaurantMenu(); DataLayer.DataEntity.Stockitems _stock = new DataLayer.DataEntity.Stockitems() { RestaurantId = stock.TblRestaurantId, CustomerId = stock.TblCustomerId, MenuId = stock.TblMenuId }; TblMenu menu = search_Repository.ItemOutOfStock(_stock.RestaurantId, _stock.MenuId); menuObj.quantity = menu.quantity; ItemStockMessage restaurantStock = new ItemStockMessage { TblRestaurantId = stock.TblRestaurantId, TblMenuId = stock.TblMenuId, TblCustomerId = stock.TblCustomerId, Message = "Item Out of Stock" }; if (menuObj.quantity == 0) { messageSend.SendMessagesAsync(restaurantStock); } return(menuObj.quantity); }
public async Task SendMessagesAsync(ItemStockMessage restaurantStock) { ITopicClient topicClient; topicClient = new TopicClient(_configuration.GetConnectionString("ServiceBusConnectionString"), TOPIC_PATH); ItemStockMessage restaurantstock = new ItemStockMessage { TblRestaurantId = restaurantStock.TblRestaurantId, TblMenuId = restaurantStock.TblMenuId, TblCustomerId = restaurantStock.TblCustomerId, Message = "Item Out of Stock" }; string data = JsonConvert.SerializeObject(restaurantstock); Message message = new Message(Encoding.UTF8.GetBytes(data)); message.UserProperties["messageType"] = typeof(ItemStockMessage).Name; try { await topicClient.SendAsync(message); } catch (Exception e) { throw e; } }
public int ItemInStock(int restaurantID, int menuID, int customerID) { RestaurantMenu menuObj = new RestaurantMenu(); TblMenu menu = search_Repository.ItemInStock(restaurantID, menuID); menuObj.quantity = menu.quantity; ItemStockMessage restaurantStock = new ItemStockMessage { TblRestaurantId = restaurantID, TblMenuId = menuID, TblCustomerId = customerID, Message = "Item Out of Stock" }; if (menuObj.quantity == 0) { messageSend.SendMessagesAsync(restaurantStock); } return(menuObj.quantity); }