I am working on a Vidly style web application after watching those training videos. Throughout the code I am returning similar things such as
SalesRepName = c.Customer.SalesRep.FirstName + ", " + c.Customer.SalesRep.LastName,
Or
Math.Round(q.QuoteLineItems.Where(li => li.Quote.Id == q.Id & li.QuoteLineItemType.Id != 8).Sum(lis => lis.TotalPrice), 2),
and I have these throughout different controllers / routes. I would like to have the logic for these methods in one location. However I can’t seem to think of a reasonable place for them.
I was thinking maybe I could have a static method in my model class such that I could do something along the lines of
public static double Quote.SumLineitems(params int[] ids) {}
but then I would need a _context there and then my model is getting all messy ( or so it seems ).
I thought maybe I could add it to my controller but again I feel this gets confusing because my controllers really seem to be more for routes and not “utility” methods.