示例#1
0
        public async Task ConvertToInvoiceAsync(Guid salesOrderId)
        {
            SalesOrder salesOrder = await _salesOrderRepository.GetSingleBySpecificationAsync(new SalesOrderSpecification(salesOrderId));

            Address  billingAddress;
            Customer customer = await _customerRepository.GetSingleBySpecificationAsync(new CustomerSpecification(salesOrder.CustomerId.Value));

            billingAddress = customer.BillingAddress;

            List <SalesInvoiceItem> invoiceLines = salesOrder.SalesOrderItems.Select(salesOrderLine =>
            {
                InvoicedItem invoicedItem    = new (salesOrderLine.ItemOrdered.ItemId, salesOrderLine.ItemOrdered.ItemName, salesOrderLine.ItemOrdered.ItemDescription);
                SalesInvoiceItem invoiceLine = new(invoicedItem, salesOrderLine.UnitPrice, salesOrderLine.Units, null);
                return(invoiceLine);
            }).ToList();

            NumberSequence numberSequence = await _numberSequenceRepository.GetSingleBySpecificationAsync(new NumberSequenceSpecification(typeof(SalesInvoice).Name));

            int invoiceCount = await _salesInvoiceRepository.CountAllAsync();

            string invoiceNumber = numberSequence.GenerateSequence(invoiceCount);

            SalesInvoiceNote invoiceNote = await _salesInvoiceNoteRepository.GetSingleBySpecificationAsync(new SalesInvoiceNoteSpecification());

            SalesInvoice invoice = new SalesInvoice(invoiceNumber, DateTime.Now, invoiceNote?.Description, salesOrder.CustomerId, salesOrderId, billingAddress, invoiceLines);

            await _salesInvoiceRepository.AddAsync(invoice);
        }
示例#2
0
        public async Task <IActionResult> Edit(int id, [Bind("NumberSequenceId,NumberSequenceName,Module,Prefix,LastNumber,MyProperty,createdAt")] NumberSequence numberSequence)
        {
            if (id != numberSequence.NumberSequenceId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(numberSequence);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NumberSequenceExists(numberSequence.NumberSequenceId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(numberSequence));
        }
        public void SetCurrentDisplayValue(NumberSequence nsequence)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                con.Open();
                using (SqlCommand cm = new SqlCommand("SetCurrentDisplayValue", con))
                {
                    cm.CommandType = System.Data.CommandType.StoredProcedure;

                    DatabaseHelper.InsertStringNVarCharParam("@newValue", cm, nsequence.CurrentValue);
                    DatabaseHelper.InsertStringNVarCharParam("@AlphaPart", cm, nsequence.AlphaPart);
                    DatabaseHelper.InsertInt32Param("@Integerpart", cm, nsequence.IntegerPart);
                    DatabaseHelper.InsertInt32Param("@numSeqID", cm, nsequence.Id);

                    cm.Parameters["@newValue"].Direction    = ParameterDirection.Output;
                    cm.Parameters["@Integerpart"].Direction = ParameterDirection.Output;
                    cm.Parameters["@AlphaPart"].Direction   = ParameterDirection.Output;

                    cm.ExecuteNonQuery();

                    nsequence.IntegerPart  = (int)cm.Parameters["@Integerpart"].Value;
                    nsequence.AlphaPart    = cm.Parameters["@AlphaPart"].Value.ToString();
                    nsequence.CurrentValue = cm.Parameters["@newValue"].Value.ToString();
                }
            }
        }
示例#4
0
        public async Task <IActionResult> Create([Bind("NumberSequenceId,NumberSequenceName,Module,Prefix,LastNumber,MyProperty,createdAt")] NumberSequence numberSequence)
        {
            if (ModelState.IsValid)
            {
                _context.Add(numberSequence);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(numberSequence));
        }
        static void Main(string[] args)
        {
            int[] intArr = new int[] { -23, -1, 12, 45, 13, 2, 1, 90, 4 };
            double[] doubleArr = new double[] { 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8 };
            byte[] byteArr = new byte[] { 2, 1, 5, 3, 2 };

            NumberSequence<int> intSequence = new NumberSequence<int>(intArr);
            Console.WriteLine(intSequence);
            NumberSequence<double> doubleSequence = new NumberSequence<double>(doubleArr);
            Console.WriteLine(doubleSequence);
            NumberSequence<byte> byteSequence = new NumberSequence<byte>(byteArr);
            Console.WriteLine(byteSequence);
        }