Example #1
0
        public async Task <IActionResult> GetInvoice(int id)
        {
            int userId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);

            Invoice invoice = await _repo.GetSingleInvoice(userId, id);

            InvoiceForReturnDto invoiceForReturn = _mapper.Map <InvoiceForReturnDto>(invoice);

            return(Ok(invoiceForReturn));
        }
Example #2
0
        public async Task <IActionResult> AddInvoice(string startDate, string endDate, InvoiceForCreationDto invoiceForCreation)
        {
            int userId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);

            string sql = $"EXEC dbo.spUpdateClockItemsInvoiced @Invoiced=1, @Date='{invoiceForCreation.Date}', @Customer='{invoiceForCreation.Customer}', " +
                         $"@InvoiceNumber={invoiceForCreation.InvoiceNumber}, @StartDate='{startDate}', @EndDate='{endDate}', " +
                         $"@DateRange='{invoiceForCreation.DateRange}', @UserId={userId}";

            Console.WriteLine(sql);

            Invoice invoice = await _sqlAccess.ExecuteProcedure <Invoice>(sql);

            InvoiceForReturnDto invoiceToReturn = _mapper.Map <InvoiceForReturnDto>(invoice);

            return(CreatedAtRoute("GetInvoice", new { id = invoice.Id }, invoiceToReturn));

            throw new Exception("Creation of invoice failed on save");
        }