public bool AddOrder(OrderModel orderModel) { using (var work = new ErrandsUnitOfWork()) { work.GetRepository <OrderModel>().Insert(orderModel); work.Commit(); } return(true); }
public IEnumerable <OrderModel> GetOrders(string seachPattern) { using (var work = new ErrandsUnitOfWork()) { var repository = work.GetRepository <OrderModel>(); if (string.IsNullOrEmpty(seachPattern)) { return(repository.GetAll()); } return(repository.GetAll(p => p.AddressFrom.Contains(seachPattern) || p.AddressTo.Contains(seachPattern) || p.Commentary.Contains(seachPattern))); } }
public IEnumerable <Coordinate> GetCoordinatesOfOrder(int orderId) { using (var work = new ErrandsUnitOfWork()) { var order = work.GetRepository <OrderModel>().Get(orderId); if (order == null) { return(Enumerable.Empty <Coordinate>()); } return(order.Coordinates); } }
public bool AddCoordinateToOrder(int orderId, Coordinate coordinate) { using (var work = new ErrandsUnitOfWork()) { var order = work.GetRepository <OrderModel>().Get(orderId); if (order == null) { return(false); } order.Coordinates.Add(coordinate); work.Commit(); } return(true); }