public async Task <IActionResult> Document(int passId, bool itsForDocument = true) { if (passId != 0) { var pass = await passRepository.GetAll() .Where(p => p.Id == passId) .Include(p => p.Visitor).ThenInclude(v => v.Document).ThenInclude(d => d.DocumentType) .Include(p => p.Visitor).ThenInclude(v => v.Document).ThenInclude(d => d.IssuingAuthority) .Include(p => p.StationFacilities) .FirstAsync(); var documentVM = new CommonInformationVM { Document = pass.Visitor.Document, Id = pass.Id, Name = pass.Visitor.Name, LastName = pass.Visitor.LastName, Patronymic = pass.Visitor.LastName, PassType = "Разрешение на съемку", ValidWith = pass.ValidWith.ToString("dd:mm yyyy-hh-mm"), ValitUntil = pass.ValitUntil.ToString("dd:mm yyyy-hh-mm"), PlaceOfWork = pass.Visitor.PlaceOfWork, Position = pass.Visitor.Position, PurposeOfIssuance = pass.ShootingPurpose, StationFacilities = pass.StationFacilities.Select(f => f.Value).ToList(), CameraType = pass.CameraType }; if (itsForDocument) { return(View("Document", documentVM)); } if (!itsForDocument) { return(View("CommonPassInfo", documentVM)); } } return(BadRequest()); }
public async Task <IActionResult> Document(int passId, bool itsForDocument = true) { if (passId != 0) { var pass = await passRepository.GetAll() .Where(p => p.Id == passId) .Include(p => p.Visitor).ThenInclude(v => v.Document).ThenInclude(d => d.DocumentType) .Include(p => p.Visitor).ThenInclude(v => v.Document).ThenInclude(d => d.IssuingAuthority) .Include(p => p.Car) .FirstAsync(); var documentVM = new CommonInformationVM { Document = pass.Visitor.Document, Id = pass.Id, Name = pass.Visitor.Name, LastName = pass.Visitor.LastName, Patronymic = pass.Visitor.LastName, PassType = "Транспортный пропуск", ValidWith = pass.ValidWith.ToLongDateString(), ValitUntil = pass.ValitUntil.ToLongDateString(), PlaceOfWork = pass.Visitor.PlaceOfWork, Position = pass.Visitor.Position, PurposeOfIssuance = pass.PurposeOfIssuance, Car = pass.Car }; if (itsForDocument) { return(View("Document", documentVM)); } if (!itsForDocument) { return(View("CommonPassInfo", documentVM)); } } return(BadRequest()); }