public void CheckOut(ApplicationUser user) { IEnumerable <Order> orders = _orderRepo.GetOrdersForUser(user.Id); List <Order> newOrders = new List <Order>(); orders.Select(order => { if (order.OrderLine == null) { newOrders.Add(order); _orderLineRepo.SetEntityState(order, EntityState.Unchanged); } return(order); }); OrderLine line = new OrderLine() { User = user, Orders = newOrders, Date = DateTime.Now, Delivered = false }; _orderLineRepo.SetEntityState(user, EntityState.Unchanged); _orderLineRepo.Insert(line); _orderLineRepo.SaveChanges(); //add to queue //string json = JsonConvert.SerializeObject(line); }
private void SetStateUnchanged <T>(IEnumerable <T> list) where T : class { foreach (T item in list) { _deviceRepo.SetEntityState(item, EntityState.Unchanged); } }