public static IEnumerable<CustomerSearchResult> SearchByFamilyNameAndName(string FamilyNameTerm, string NameTerm) { using (PosManagerContext ctx = new PosManagerContext()) { return ctx.Set<Customer>() .Where(c => (c.FamilyName.Contains(FamilyNameTerm)) || (c.Name.Contains(NameTerm))) .Select(c => new CustomerSearchResult { Id = c.Id, Name = c.Name, FamilyName = c.FamilyName, Street = c.Street }) .ToList(); } }
public static void DeletePlanType(int id) { using (PosManagerContext ctx = new PosManagerContext()) { if (ctx.Plans.Any(p => p.PlanTypeId == id)) { throw new RelatedEntityExistsException(); } } CommonDAL.DeleteEntityById<PlanType>(id); }
public static Customer GetCustomerById(int cid) { using (PosManagerContext ctx = new PosManagerContext()) { ctx.Configuration.ProxyCreationEnabled = false; return ctx.Customers.Include(c => c.Plans) .Include(c => c.Plans .Select(p => p.Discounts .Select(d => d.DiscountType) .Select(dt => dt.Product))) .Include(c => c.Plans.Select(p => p.PlanType)) .FirstOrDefault(c => c.Id == cid); } }
public static ICollection<PlanType> GetAllPlanTypes(string locale) { try { using (var ctx = new PosManagerContext()) { ctx.Configuration.ProxyCreationEnabled = false; return ctx.PlanTypes.Include(pt => pt.DiscountTypes.Select(dt => dt.Product)).ToList(); } } catch (Exception e) { throw new GetAllEntitiesException(e); } }
public static ICollection<Plan> GetAllPlans(string locale) { try { using (var ctx = new PosManagerContext()) { IList<Plan> plans = ctx.Plans.ToList(); plans = plans.TranslateMany(locale); return plans; } } catch (Exception e) { throw new GetAllEntitiesException(e); } }
public static ICollection<DiscountType> GetAllDiscountTypes(string locale) { try { using (var ctx = new PosManagerContext()) { IList<DiscountType> discountTypes = ctx.DiscountTypes.ToList(); discountTypes = discountTypes.TranslateMany(locale); return discountTypes; } } catch (Exception e) { throw new GetAllEntitiesException(e); } }