public async Task <IActionResult> Edit(int id, ProjectClientViewModelcs projectClientViewModelcs, int clientid, int statusid, int projectid)
        {
            if (ModelState.IsValid)
            {
                if (projectClientViewModelcs.Invoice == null)
                {
                    return(NotFound());
                }
                var proje = await _context.Projects.FindAsync(projectid);

                var client = await _context.Clients.FindAsync(clientid);

                var status = ((PaymentStatus)statusid).ToString();

                var invoiceInfo = await _context.Invoices.FindAsync(id);

                invoiceInfo.NetAmount   = projectClientViewModelcs.Invoice.NetAmount;
                invoiceInfo.TaxAmount   = projectClientViewModelcs.Invoice.TaxAmount;
                invoiceInfo.Note        = projectClientViewModelcs.Invoice.Note;
                invoiceInfo.TotalAmount = projectClientViewModelcs.Invoice.TotalAmount;
                invoiceInfo.DateTime    = projectClientViewModelcs.Invoice.DateTime;
                invoiceInfo.ProjectId   = projectid;
                invoiceInfo.ClientId    = clientid;
                invoiceInfo.Project     = proje;
                invoiceInfo.Client      = client;
                invoiceInfo.Status      = status;

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }
        public async Task <IActionResult> Create()
        {
            ProjectClientViewModelcs vm = new ProjectClientViewModelcs()
            {
                Invoice  = new Models.BLL.Invoice(),
                Clients  = await _context.Clients.ToListAsync(),
                Projects = await _context.Projects.ToListAsync()
            };

            return(View(vm));
        }
        public async Task <IActionResult> Index()
        {
            ProjectClientViewModelcs vm = new ProjectClientViewModelcs()
            {
                Invoice  = new Invoice(),
                Invoices = await _context.Invoices.Include(c => c.Client).Include(p => p.Project).ToListAsync(),
                Clients  = await _context.Clients.ToListAsync(),
                Projects = await _context.Projects.ToListAsync()
            };

            return(View(vm));
        }
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var invoice = await _context.Invoices.FindAsync(id);

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

            ProjectClientViewModelcs viewModel = new ProjectClientViewModelcs()
            {
                Clients  = await _context.Clients.ToListAsync(),
                Invoice  = invoice,
                Projects = await _context.Projects.ToListAsync()
            };

            return(View(viewModel));
        }
        public async Task <IActionResult> Create(ProjectClientViewModelcs projectClientViewModelcs,
                                                 int clientid, int statusid, int projectid)
        {
            if (ModelState.IsValid)
            {
                if (projectClientViewModelcs.Invoice == null)
                {
                    return(NotFound());
                }
                var proje = await _context.Projects.FindAsync(projectid);

                var client = await _context.Clients.FindAsync(clientid);

                var status = ((PaymentStatus)statusid).ToString();

                Invoice invoice = new Invoice()
                {
                    NetAmount   = projectClientViewModelcs.Invoice.NetAmount,
                    TaxAmount   = projectClientViewModelcs.Invoice.TaxAmount,
                    TotalAmount = projectClientViewModelcs.Invoice.TotalAmount,
                    Note        = projectClientViewModelcs.Invoice.Note,
                    DateTime    = projectClientViewModelcs.Invoice.DateTime,
                    ProjectId   = projectid,
                    ClientId    = clientid,
                    Project     = proje,
                    Client      = client,
                    Status      = status
                };

                await _context.Invoices.AddAsync(invoice);

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }