Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save forenheith/41dfd8dba05511ab9914b0da3cd48de1 to your computer and use it in GitHub Desktop.
Save forenheith/41dfd8dba05511ab9914b0da3cd48de1 to your computer and use it in GitHub Desktop.
ex
public ICollection<TicketViewModel> GetTicketsCollection(TicketFilterViewModel model)
{
List<TicketViewModel> ticketsViewModelsCollection;
using (var ticketsRepo = this.RepoFactory.GetTicketsRepository())
{
if (model.EmployeeId == null)
{
/* get departments tickets*/
ticketsViewModelsCollection = ticketsRepo.GetAll(
m => model.Direction == TicketDirection.In
/*inbox*/
? m.RecipientId == model.DepartmentId
/*outbox*/
: m.SenderId == model.DepartmentId).Select(ModelsMapper.GetTicketViewModel).ToList();
if (model.States != null)
ticketsViewModelsCollection =
ticketsViewModelsCollection.Where(
m => m.StateId == model.StateId).ToList();
}
else
{
/* get employees tickets*/
ticketsViewModelsCollection = ticketsRepo.GetAll(
m => model.Direction == TicketDirection.In
/*inbox*/
? m.RecipientId == model.EmployeeId
/*outbox*/
: m.SenderId == model.EmployeeId).Select(ModelsMapper.GetTicketViewModel).ToList();
}
}
return ticketsViewModelsCollection;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment