public List<BuildingPrimitive> GetBuildings(string filter, ListItemsFilterValues listItemsFilterValue) { try { using (var ctx = new SmartWorkingEntities()) { List<Building> result = (string.IsNullOrWhiteSpace(filter)) ? (listItemsFilterValue == ListItemsFilterValues.All) ? ctx.Buildings.ToList() : (listItemsFilterValue == ListItemsFilterValues.IncludeDeactive) ? ctx.Buildings.Where(x => !x.Deleted.HasValue).ToList() : ctx.Buildings.Where(x => !x.Deleted.HasValue && !x.Deactivated.HasValue).ToList() : (listItemsFilterValue == ListItemsFilterValues.All) ? ctx.Buildings.Where(x => (x.InternalName.Contains(filter) || x.Name.Contains(filter))).ToList() : (listItemsFilterValue == ListItemsFilterValues.IncludeDeactive) ? ctx.Buildings.Where(x => !x.Deleted.HasValue && (x.InternalName.Contains(filter) || x.Name.Contains(filter))).ToList() : ctx.Buildings.Where(x => !x.Deleted.HasValue && !x.Deactivated.HasValue && (x.InternalName.Contains(filter) || x.Name.Contains(filter))).ToList(); return result.Select(x => x.GetPrimitive()).ToList(); ; } } catch (Exception e) { throw new FaultException<ExceptionDetail>(new ExceptionDetail(e), e.Message); } }
/// <summary> /// Gets the <see cref="DeliveryNote"/> filtered be <paramref name="filter"/> and <paramref name="showCanceledDeliveryNotes"/>. /// </summary> /// <param name="filter">Used to filtering result. Loaded <see cref="DeliveryNote"/> object will contain this string.</param> /// <param name="showCanceledDeliveryNotes">if set to <c>true</c> then loaded <see cref="DeliveryNote"/> object will contain <see cref="DeliveryNote"/> which are deactivated; otherwise not.</param> /// <returns> /// List of <see cref="DeliveryNote"/> filtered by <paramref name="filter"/> and <paramref name="showCanceledDeliveryNotes"/>. /// </returns> public List<DeliveryNotePrimitive> GetDeliveryNotes(string filter, ListItemsFilterValues listItemsFilterValue) { try { using (var ctx = new SmartWorkingEntities()) { List<DeliveryNote> result; //if (string.IsNullOrWhiteSpace(filter)) //{ // if (showCanceledDeliveryNotes) // { // result = ctx.DeliveryNotes.Include("Building.Contractor").Include("Recipe").Include("Driver").Include("Car").ToList(); // } // else // { // result = ctx.DeliveryNotes.Include("Building.Contractor").Include("Recipe").Include("Driver").Include("Car").Where(x => x.Canceled != DateTime.MinValue).ToList(); // } //} //else //{ // if (showCanceledDeliveryNotes) // { // result = ctx.DeliveryNotes.Include("Building.Contractor").Include("Recipe").Include("Driver").Include("Car").Where(x => (x.Building.City + " " + x.Building.Street).Contains(filter)).ToList(); // } // else // { // result = ctx.DeliveryNotes.Include("Building.Contractor").Include("Recipe").Include("Driver").Include("Car").Where(x => x.Canceled != DateTime.MinValue && (x.Building.City + " " + x.Building.Street).Contains(filter)).ToList(); // } //} //return result.Select(x => x.GetPrimitive()).ToList(); return null; } } catch (Exception e) { throw new FaultException<ExceptionDetail>(new ExceptionDetail(e), e.Message); } }
/// <summary> /// Gets the recipes filtered be <paramref name="recipesFilter"/>. /// </summary> /// <param name="recipesFilter">The recipes filter.</param> /// <returns> /// List of Recipe filtered by <paramref name="recipesFilter"/>. Recipe contains list of Material contains to this Recipe. /// </returns> public List<RecipePrimitive> GetRecipes(string filter, ListItemsFilterValues listItemsFilterValue) { try { using (var ctx = new SmartWorkingEntities()) { List<Recipe> result = (string.IsNullOrWhiteSpace(filter)) ? (listItemsFilterValue == ListItemsFilterValues.All) ? ctx.Recipes.ToList() : (listItemsFilterValue == ListItemsFilterValues.IncludeDeactive) ? ctx.Recipes.Where(x => !x.Deleted.HasValue).ToList() : ctx.Recipes.Where(x => !x.Deleted.HasValue && !x.Deactivated.HasValue).ToList() : (listItemsFilterValue == ListItemsFilterValues.All) ? ctx.Recipes.Where(x => (x.Code.StartsWith(filter))).ToList() : (listItemsFilterValue == ListItemsFilterValues.IncludeDeactive) ? ctx.Recipes.Where(x => !x.Deleted.HasValue && (x.Code.StartsWith(filter))).ToList() : ctx.Recipes.Where(x => !x.Deleted.HasValue && !x.Deactivated.HasValue && (x.Code.StartsWith(filter))).ToList(); return result.Select(x => x.GetPrimitive()).ToList(); //todo po symbolu cemnetu //ctx.Recipes.Where(x => (x.Code.Contains(filter) || // x.RecipeComponents.Where( // y => ((y.Material.MaterialType.HasValue && y.Material.MaterialType.Value == (int)MaterialTypeEnum.Concrete) && // (y.Material.InternalName.Contains(filter)))).Count() > 0 // )).ToList() } } catch (Exception e) { throw new FaultException<ExceptionDetail>(new ExceptionDetail(e), e.Message); } }
/// <summary> /// Gets the <see cref="RecipePackage"/> list filtered by <paramref name="filter"/>. /// </summary> /// <param name="filter">The contractor name filter.</param> /// <returns> /// List of contractors filtered by <paramref name="filter"/>. /// </returns> public List<RecipePackage> GetRecipePackageList(string filter, ListItemsFilterValues listItemsFilterValue) { try { using (var ctx = new SmartWorkingEntities()) { List<Recipe> result = (string.IsNullOrWhiteSpace(filter)) ? (listItemsFilterValue == ListItemsFilterValues.All) ? ctx.Recipes.Include("RecipeComponents.Material.Producer").Include("RecipeComponents.Material.Deliverer").ToList() : (listItemsFilterValue == ListItemsFilterValues.IncludeDeactive) ? ctx.Recipes.Include("RecipeComponents.Material.Producer").Include("RecipeComponents.Material.Deliverer").Where(x => !x.Deleted.HasValue).ToList() : ctx.Recipes.Include("RecipeComponents.Material.Producer").Include("RecipeComponents.Material.Deliverer").Where(x => !x.Deleted.HasValue && !x.Deactivated.HasValue).ToList() : (listItemsFilterValue == ListItemsFilterValues.All) ? ctx.Recipes.Include("RecipeComponents.Material.Producer").Include("RecipeComponents.Material.Deliverer").Where(x => (x.Code.StartsWith(filter))).ToList() : (listItemsFilterValue == ListItemsFilterValues.IncludeDeactive) ? ctx.Recipes.Include("RecipeComponents.Material.Producer").Include("RecipeComponents.Material.Deliverer").Where(x => !x.Deleted.HasValue && (x.Code.StartsWith(filter))).ToList() : ctx.Recipes.Include("RecipeComponents.Material.Producer").Include("RecipeComponents.Material.Deliverer").Where(x => !x.Deleted.HasValue && !x.Deactivated.HasValue && (x.Code.StartsWith(filter))).ToList(); return result.Select(x => x.GetRecipesPackage()).ToList(); } } catch (Exception e) { throw new FaultException<ExceptionDetail>(new ExceptionDetail(e), e.Message); } }
public List<UserAndRolesPackage> GetUserAndRolesPackageList(string filter, ListItemsFilterValues listItemsFilterValue) { try { using (var ctx = new SmartWorkingEntities()) { List<User> result = (string.IsNullOrWhiteSpace(filter)) ? (listItemsFilterValue == ListItemsFilterValues.All) ? ctx.Users.Include("Roles").ToList() : (listItemsFilterValue == ListItemsFilterValues.IncludeDeactive) ? ctx.Users.Include("Roles").Where(x => !x.Deleted.HasValue).ToList() : ctx.Users.Include("Roles").Where(x => !x.Deleted.HasValue && !x.Deactivated.HasValue).ToList() : (listItemsFilterValue == ListItemsFilterValues.All) ? ctx.Users.Include("Roles").Where(x => (x.Name.StartsWith(filter))).ToList() : (listItemsFilterValue == ListItemsFilterValues.IncludeDeactive) ? ctx.Users.Include("Roles").Where(x => !x.Deleted.HasValue && (x.Name.StartsWith(filter))).ToList() : ctx.Users.Include("Roles").Where(x => !x.Deleted.HasValue && !x.Deactivated.HasValue && (x.Name.StartsWith(filter))).ToList(); List<UserAndRolesPackage> toReturn = result.Select(x => x.GetUserAndRolesPackage()).ToList(); foreach(UserAndRolesPackage userAndRolesPackage in toReturn) { if (userAndRolesPackage != null) { userAndRolesPackage.PasswordConfirm = string.Empty; userAndRolesPackage.User.Password = string.Empty; userAndRolesPackage.User.PasswordSalz = string.Empty; } } return toReturn; } } catch (Exception e) { throw new FaultException<ExceptionDetail>(new ExceptionDetail(e), e.Message); } }
/// <summary> /// Gets the <see cref="ClientAndClientBuildingsPackage"/> list filtered by <paramref name="filter"/>. /// </summary> /// <param name="filter">The client name filter.</param> /// <returns> /// List of clients filtered by <paramref name="filter"/>. /// </returns> public List<ClientAndClientBuildingsPackage> GetClientAndBuildingsPackageList(string filter, ListItemsFilterValues listItemsFilterValue) { try { using (var ctx = new SmartWorkingEntities()) { List<Client> result = (string.IsNullOrWhiteSpace(filter)) ? (listItemsFilterValue == ListItemsFilterValues.All) ? ctx.Clients.ToList() : (listItemsFilterValue == ListItemsFilterValues.IncludeDeactive) ? ctx.Clients.Where(x => !x.Deleted.HasValue).ToList() : ctx.Clients.Where(x => !x.Deleted.HasValue && !x.Deactivated.HasValue).ToList() : (listItemsFilterValue == ListItemsFilterValues.All) ? ctx.Clients.Where(x => (x.InternalName.Contains(filter) || x.Name.Contains(filter))).ToList() : (listItemsFilterValue == ListItemsFilterValues.IncludeDeactive) ? ctx.Clients.Where(x => !x.Deleted.HasValue && (x.InternalName.Contains(filter) || x.Name.Contains(filter))).ToList() : ctx.Clients.Where(x => !x.Deleted.HasValue && !x.Deactivated.HasValue && (x.InternalName.Contains(filter) || x.Name.Contains(filter))).ToList(); List<int> clientIds = result.Select(x => x.Id).ToList(); List<ClientBuilding> clientBuildings = ctx.ClientBuildings.Include("Building").Where(cb => clientIds.Contains(cb.Client.Id) && !cb.Deleted.HasValue && cb.Building != null && !cb.Building.Deleted.HasValue).ToList(); return result.Select(x => x.GetClientAndBuildingsPackage()).ToList(); } } catch (Exception e) { throw new FaultException<ExceptionDetail>(new ExceptionDetail(e), e.Message); } }
public List<CarAndDriverPackage> GetCarAndDriverPackageList(string filter, ListItemsFilterValues listItemsFilterValue) { try { using (var ctx = new SmartWorkingEntities()) { List<Car> result = (string.IsNullOrWhiteSpace(filter)) ? (listItemsFilterValue == ListItemsFilterValues.All) ? ctx.Cars.Include("Driver").ToList() : (listItemsFilterValue == ListItemsFilterValues.IncludeDeactive) ? ctx.Cars.Include("Driver").Where(x => !x.Deleted.HasValue).ToList() : ctx.Cars.Include("Driver").Where(x => !x.Deleted.HasValue && !x.Deactivated.HasValue).ToList() : (listItemsFilterValue == ListItemsFilterValues.All) ? ctx.Cars.Include("Driver").Where(x => (x.InternalName.Contains(filter) || x.RegistrationNumber.Contains(filter))).ToList() : (listItemsFilterValue == ListItemsFilterValues.IncludeDeactive) ? ctx.Cars.Include("Driver").Where(x => !x.Deleted.HasValue && (x.InternalName.Contains(filter) || x.RegistrationNumber.Contains(filter))).ToList() : ctx.Cars.Include("Driver").Where(x => !x.Deleted.HasValue && !x.Deactivated.HasValue && (x.InternalName.Contains(filter) || x.RegistrationNumber.Contains(filter))).ToList(); return result.Select(x => x.GetCarAndDriverPackage()).ToList(); } } catch (Exception e) { throw new FaultException<ExceptionDetail>(new ExceptionDetail(e), e.Message); } }
public List<OrderPackage> GetOrderPackageList(string filter, ListItemsFilterValues listItemsFilterValue) { try { using (var ctx = new SmartWorkingEntities()) { List<Order> result = (string.IsNullOrWhiteSpace(filter)) ? (listItemsFilterValue == ListItemsFilterValues.All) ? ctx.Orders.Include("DeliveryNotes.Car").Include("DeliveryNotes.Driver").Include("Recipe").Include("ClientBuilding.Client").Include("ClientBuilding.Building").ToList() : (listItemsFilterValue == ListItemsFilterValues.IncludeDeactive) ? ctx.Orders.Include("DeliveryNotes.Car").Include("DeliveryNotes.Driver").Include("Recipe").Include("ClientBuilding.Client").Include("ClientBuilding.Building").Where(x => !x.Deleted.HasValue).ToList() : ctx.Orders.Include("DeliveryNotes.Car").Include("DeliveryNotes.Driver").Include("Recipe").Include("ClientBuilding.Client").Include("ClientBuilding.Building").Where(x => !x.Deleted.HasValue && !x.Deactivated.HasValue).ToList() : (listItemsFilterValue == ListItemsFilterValues.All) ? ctx.Orders.Include("DeliveryNotes.Car").Include("DeliveryNotes.Driver").Include("Recipe").Include("ClientBuilding.Client").Include("ClientBuilding.Building").Where(x => x.ClientBuilding != null && x.ClientBuilding.Client != null && x.ClientBuilding.Client.Name.Contains(filter)).ToList() : (listItemsFilterValue == ListItemsFilterValues.IncludeDeactive) ? ctx.Orders.Include("DeliveryNotes.Car").Include("DeliveryNotes.Driver").Include("Recipe").Include("ClientBuilding.Client").Include("ClientBuilding.Building").Where(x => !x.Deleted.HasValue && x.ClientBuilding != null && x.ClientBuilding.Client != null && x.ClientBuilding.Client.Name.Contains(filter)).ToList() : ctx.Orders.Include("DeliveryNotes.Car").Include("DeliveryNotes.Driver").Include("Recipe").Include("ClientBuilding.Client").Include("ClientBuilding.Building").Where(x => !x.Deleted.HasValue && !x.Deactivated.HasValue && x.ClientBuilding != null && x.ClientBuilding.Client != null && x.ClientBuilding.Client.Name.Contains(filter)).ToList(); return result.Select(x => x.GetOrderPackage()).ToList(); } } catch (Exception e) { throw new FaultException<ExceptionDetail>(new ExceptionDetail(e), e.Message); } }