public void export(List <ProgramareExport> programari)
        {
            List <ProgramareViewModel> programareViewModels = new List <ProgramareViewModel>();

            foreach (ProgramareExport programare in programari)
            {
                ProgramareViewModel programareViewModel = new ProgramareViewModel();
                programareViewModel.ProgramareId = programare.ProgramareId;
                programareViewModel.numeClient   = programare.numeClient;
                programareViewModel.telefon      = programare.telefon;
                programareViewModel.dataOra      = programare.dataOra;
                programareViewModel.cost         = programare.cost;

                programareViewModels.Add(programareViewModel);
            }

            DataTableUtility dataTableUtility = new DataTableUtility();
            DataTable        dataTable        = dataTableUtility.ConvertToDataTable(programareViewModels);

            SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");

            var workbook  = new ExcelFile();
            var worksheet = workbook.Worksheets.Add("DataTable to Sheet");

            worksheet.Cells[0, 0].Value = "Programari:";

            worksheet.InsertDataTable(dataTable,
                                      new InsertDataTableOptions()
            {
                ColumnHeaders = true,
                StartRow      = 2
            });

            workbook.Save("Programari.xlsx");
        }
        // GET: Programare/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ProgramareViewModel programareViewModel = _programareService.costTotal(id.GetValueOrDefault());

            if (programareViewModel == null)
            {
                return(NotFound());
            }

            return(View(programareViewModel));
        }
        public ProgramareViewModel costProgramare(int programareId)
        {
            Programare          programare          = GetByID(programareId);
            ProgramareViewModel programareViewModel = new ProgramareViewModel();

            programareViewModel.ProgramareId = programare.ProgramareId;
            programareViewModel.numeClient   = programare.numeClient;
            programareViewModel.dataOra      = programare.dataOra;
            programareViewModel.telefon      = programare.telefon;
            float cost = 0.0f;

            List <Serviciu> servicii = _context.Serviciu.Where(ps => ps.ProgramareServiciu.Any(p => p.Programare.ProgramareId == programareId)).ToList();

            foreach (Serviciu serviciu in servicii)
            {
                cost += serviciu.pret;
            }

            programareViewModel.cost = cost;

            return(programareViewModel);
        }