public static Dictionary GetInvoiceStatusByNumber(int number) { Repository<Dictionary, Guid> rep = new Repository<Dictionary, Guid>(); var result = from dict in rep.GetQueryable() where dict.DictionaryType.Name == DictionaryTypeNames.Invoice && dict.DictionaryNumber == number select dict; return result.SingleOrDefault(); }
public static IList<Invoice> GetInvoices(Dictionary status) { Repository<Invoice, Guid> rep = new Repository<Invoice, Guid>(); var result = from i in rep.GetQueryable() select i; if (status != null) result = result.Where(i => i.InvoiceStatus == status); return result.ToList(); }
public static IList<Contact> GetContacts(CustomerFacility fac) { if (fac == null) return null; if (fac.CustomerFacilityID == Guid.Empty) return null; Repository<Contact, Guid> contactRep = new Repository<Contact,Guid>(); IEnumerable<Contact> contacts = new List<Contact>(); contacts = contactRep.GetAll().Where(c => fac.Contacts.Contains(c)); return contacts.ToList(); }
public static IList<CustomerFacility> GetFacilitiesForCustomer(Customer customer) { if (customer == null) return null; Repository<CustomerFacility, Guid> repo = new Repository<CustomerFacility, Guid>(); var result = repo.GetAll(); return result.Where(fac => fac.Customer.CustomerID == customer.CustomerID).ToList(); }
public static IList<CustomerFacility> GetFacilitiesForContact(Contact contact) { Repository<CustomerFacility, Guid> repo = new Repository<CustomerFacility, Guid>(); var result = repo.GetQueryable().Where(fac => fac.Contacts.Contains(contact)); return result.ToList(); }
public static IList<CustomerFacility> GetFacilities(string name,Customer customer, Territory territory) { Repository<CustomerFacility, Guid> repo = new Repository<CustomerFacility, Guid>(); var result = repo.GetAll() .Where(fac => fac.Name.Contains(name)); if (customer != null) result = result.Where(fac => fac.Customer.CustomerID == customer.CustomerID); if (territory != null) { result = result.Where(fac => fac.Territory.TerritoryID == territory.TerritoryID); IList<Territory> allTerr = GetAllChildTerritories(territory); allTerr.Add(territory); var allTerrId = from pG in allTerr select pG.TerritoryID; result = from p in result where allTerrId.Contains(p.Territory.TerritoryID) select p; } return result.ToList(); }
public static IList<Task> GetNewestTaskForEmployee(Employee emp, int howMany) { Repository<Task, Guid> rep = new Repository<Task, Guid>(); var result = from t in rep.GetQueryable() where t.AssignedTo == emp && t.TaskStatus.DictionaryNumber != (byte)TaskStatusEnum.Zakonczone orderby t.DateCreated ascending select t; return result.Take(howMany).ToList(); }
public static IList<Task> GetTaskToApprove(Employee emp, int howMany) { Repository<Task, Guid> rep = new Repository<Task, Guid>(); var result = from t in rep.GetQueryable() where t.GivenBy == emp && t.DateExecuted != null orderby t.DateExecuted ascending select t; return result.Take(howMany).ToList(); }
public static Dictionary GetTaskStatusByName(string name) { Repository<Dictionary, Guid> rep = new Repository<Dictionary, Guid>(); var result = from dict in rep.GetQueryable() where dict.DictionaryType.Name == "Status zadania" && dict.Value == name select dict; return result.SingleOrDefault(); }
public static bool HasOrderInvoice(Order order) { Repository<Invoice, Guid> rep = new Repository<Invoice, Guid>(); var result = from i in rep.GetQueryable() where i.Order == order select i; if (result.Count() > 0) return true; else return false; }
public static IList<Country> GetAllCountries() { Repository<Country, Guid> rep = new Repository<Country, Guid>(); return rep.GetAll(); }
public static IList<Order> GetOrders(CustomerFacility fac) { Repository<Order, Guid> rep = new Repository<Order, Guid>(); var result = from o in rep.GetQueryable() select o; if (fac != null) result = result.Where(o => o.CustomerFacility == fac); return result.ToList(); }
private static string GenerateOrderIdentifier(Order order) { StringBuilder builder = new StringBuilder(); builder.Append(order.OrderDate.Day + "/" + order.OrderDate.Month + "/" + order.OrderDate.Year); builder.Append("_" + order.Territory.Name.Substring(0, 2)); if (order.Employee.Contact != null) { builder.Append("_" + order.Employee.Contact.FirstName.Substring(0, 1) + order.Employee.Contact.LastName.Substring(0, 1)); } Repository<Order, Guid> repOrder = new Repository<Order,Guid>(); Order newestOrder = repOrder.GetQueryable().Where(o => o.Identifier.Contains(builder.ToString())).OrderByDescending(o => o.Identifier).FirstOrDefault(); int idx = 1; if (newestOrder != null) { idx = Int32.Parse(newestOrder.Identifier.Replace(builder.ToString() + "_", "")); idx++; } builder.Append("_" + idx); return builder.ToString(); }
private static string GenerateInvoiceNumber() { string result = string.Empty; Repository<Invoice, Guid> rep = new Repository<Invoice, Guid>(); string year = DateTime.Now.Year.ToString(); var invoices = from i in rep.GetQueryable() where i.Number.Contains(year) orderby i.Number descending select i; Invoice inv = invoices.FirstOrDefault(); if (inv != null) { string number = inv.Number.Split(' ')[1]; int invNr = number.IndexOf("/"); int nr = Int32.Parse(number.Substring(0, invNr)); nr++; return "FV " + nr + "/" + year; } else return "FV 1/" + year; }
public static IList<Task> GetTasks(Employee assignedTo, Employee givenBy, Employee createdBy, Dictionary taskStatus, bool showOnlyApproved, DateTime? dateCreatedFrom, DateTime? dateCreatedTo) { Repository<Task, Guid> rep = new Repository<Task, Guid>(); var result = from t in rep.GetQueryable() select t; if (assignedTo != null) result = result.Where(t => t.AssignedTo == assignedTo); if (givenBy != null) result = result.Where(t => t.GivenBy == givenBy); if (createdBy != null) result = result.Where(t => t.CreatedBy == createdBy); if (taskStatus != null) result = result.Where(t => t.TaskStatus == taskStatus); if (dateCreatedFrom.HasValue) result = result.Where(t => t.DateCreated > dateCreatedFrom.Value); if (dateCreatedTo.HasValue) result = result.Where(t => t.DateCreated < dateCreatedTo.Value); if (showOnlyApproved) result = result.Where(t => t.IsApproved == true); return result.ToList(); }
public static IList<CustomerFacility> GetCustomerFacilitiesForContact(Contact contact) { Repository<CustomerFacility, Guid> rep = new Repository<CustomerFacility,Guid>(); var result = from cf in rep.GetQueryable() where cf.Contacts.Contains(contact) select cf; return result.ToList(); }
public static IList<Order> GetOrders(Customer customer, Employee emp, Territory terr, DateTime? startDate, DateTime? endDate, Dictionary orderStatus) { Repository<Order, Guid> rep = new Repository<Order, Guid>(); var result = from o in rep.GetQueryable() select o; if (customer != null) result = result.Where(o => o.CustomerFacility.Customer == customer); if (emp != null) result = result.Where(o => o.Employee == emp); if (terr != null) result = result.Where(o => o.Territory == terr); if (orderStatus != null) result = result.Where(o => o.OrderStatus == orderStatus); if (startDate.HasValue) result = result.Where(o => o.OrderDate > startDate.Value); if (endDate.HasValue) result = result.Where(o => o.OrderDate < endDate.Value); return result.ToList(); }