public Task PublishToQueueAsync(KitchenArea kitchenArea, ProductQueueDto productQueue) { if (connection.IsOpen) { using (var channel = connection.CreateModel()) { channel.ConfirmSelect(); var queue = channel.QueueDeclare(queue: kitchenArea.Name + " - waiting", durable: false, exclusive: false, autoDelete: false, arguments: null); string message = JsonConvert.SerializeObject(productQueue); var body = Encoding.UTF8.GetBytes(message); channel.BasicPublish(exchange: "", routingKey: kitchenArea.Name + " - waiting", basicProperties: null, body: body); channel.WaitForConfirmsOrDie(new TimeSpan(0, 0, 1)); return(Task.CompletedTask); } } return(Task.FromCanceled(_stoppingCts.Token)); }
public Product MapEntity(ProductRequest request) { KitchenArea kitchenArea = ValidateKitchenArea(request.IdKitchenArea); Product product = new Product(request.Id, request.Description, request.TimeToFinish, kitchenArea); UpdateOrderItem(product); return(product); }
public KitchenArea MapEntity(KitchenAreaRequest request) { KitchenArea kitchenArea = new KitchenArea(request.Id, request.Description); UpdateProduct(kitchenArea); UpdateOrderItem(kitchenArea); return(kitchenArea); }
private KitchenArea ValidateKitchenArea(int id) { KitchenArea kitchenArea = kitchenAreaRepository.GetInstance().Select(id).FirstOrDefault(); if (kitchenArea == null || kitchenArea.Id <= 0) { throw new InvalidRequestException(string.Format(MessageResource.InvalidRequest, FieldResource.KitchenArea.ToLower())); } return(kitchenArea); }
private void UpdateOrderItem(KitchenArea entity) { List <OrderItem> list = orderItemRepository.GetInstance().Select().Where(x => x.Product.KitchenArea.Id == entity.Id) .Select(s => new OrderItem(s.Id, s.Order, s.Product, s.Amount)).ToList(); foreach (var obj in list) { obj.Product.SetKitchenArea(entity); orderItemRepository.GetInstance().Update(obj); } }
private void UpdateProduct(KitchenArea entity) { List <Product> list = productRepository.GetInstance().Select().Where(x => x.KitchenArea.Id == entity.Id) .Select(s => new Product(s.Id, s.Description, s.TimeToFinish, s.KitchenArea)).ToList(); foreach (var obj in list) { obj.SetKitchenArea(entity); productRepository.GetInstance().Update(obj); } }
internal static void ReadKitchenAreas(this IDataReader reader, out List <KitchenArea> kitchenAreas) { kitchenAreas = new List <KitchenArea>(); #region load data from reader while (reader.Read()) { var kitchenArea = new KitchenArea { ProductPartId = reader.GetValue <int>("ProductPartId"), ExternalId = reader.GetValue <string>("ExternalId"), Name = reader.GetValue <string>("KitchenAreaName"), DisplayOrder = reader.GetValue <int>("DisplayOrder") }; kitchenAreas.Add(kitchenArea); } #endregion }
public void Description_Minimum_Length() { KitchenArea kitchenArea = new KitchenArea(1, string.Empty); Assert.Fail(); }
public void Description_Maximum_Length() { KitchenArea kitchenArea = new KitchenArea(1, "012345678901234567890123456789012345678901234567890123456789"); Assert.Fail(); }
public void KitchenAreaTest() { KitchenArea kitchenArea = new KitchenArea(1, "Test Kitchen Area"); Assert.IsTrue((kitchenArea != null && kitchenArea.Id > 0), string.Format(MessageResource.InvalidTest, FieldResource.KitchenArea)); }