Exemplo n.º 1
0
        public IEnumerable <AdditionalWorkResponse> GetAllByMarkId(int markId)
        {
            var docs = _docRepo.GetAllByMarkId(markId);
            var docsGroupedByCreator = docs.Where
                                           (v => v.Creator != null).GroupBy(d => d.Creator).Select(
                g => new Doc
            {
                Creator = g.First().Creator,
                Form    = g.Sum(v => v.Form),
            });
            var docsGroupedByNormContr = docs.Where(
                v => v.NormContr != null).GroupBy(d => d.NormContr).Select(
                g => new Doc
            {
                NormContr = g.First().NormContr,
                Form      = g.Sum(v => v.Form),
            });

            var addWork = _repository.GetAllByMarkId(markId).Select(v =>
                                                                    new AdditionalWorkResponse
            {
                Id       = v.Id,
                Employee = new EmployeeBaseResponse
                {
                    Id   = v.Employee.Id,
                    Name = v.Employee.Name,
                },
                Valuation         = v.Valuation,
                MetalOrder        = v.MetalOrder,
                DrawingsCompleted = docsGroupedByCreator.SingleOrDefault(
                    d => d.Creator.Id == v.Employee.Id)?.Form ?? 0,
                DrawingsCheck = docsGroupedByNormContr.SingleOrDefault(
                    d => d.NormContr.Id == v.Employee.Id)?.Form ?? 0,
            });

            return(addWork);
        }
Exemplo n.º 2
0
 public IEnumerable <Doc> GetAllByMarkId(int markId)
 {
     return(_repository.GetAllByMarkId(markId));
 }