Esempio n. 1
0
        public async Task <ActionResult> AddPaymentTerm([FromBody] PaymentTermDto paymentTerm)
        {
            int id          = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);
            var logineduser = await _auth.VerifyUser(id);

            PaymentTerm _newTerm = new PaymentTerm()
            {
                Status  = true,
                Company = logineduser.Company
            };

            _context.PaymentTerms.Add(_newTerm);
            await _context.SaveChangesAsync();

            foreach (var item in paymentTerm.ContentForLang)
            {
                PaymentTermLang termLang = new PaymentTermLang()
                {
                    PaymentTerm = _newTerm,
                    Language    = await _context.Languages.FirstOrDefaultAsync(s => s.code == item.Languagename),
                    Name        = item.Content,
                    Status      = true,
                };
                _context.PaymentTermLangs.Add(termLang);
                await _context.SaveChangesAsync();
            }
            return(Ok());
        }
Esempio n. 2
0
        public async Task <ActionResult> GetPaymentTermForId(int id)
        {
            PaymentTermDto data = await _context.PaymentTerms.Where(s => s.Id == id).Select(s => new PaymentTermDto()
            {
                Id             = s.Id,
                ContentForLang = s.PaymentTermLangs.Select(l => new SimpleforDtos.LangcontentDto()
                {
                    Content      = l.Name,
                    Languagename = l.Language.code
                }).ToList()
            }).FirstOrDefaultAsync();

            return(Ok(data));
        }
Esempio n. 3
0
        public async Task <ActionResult> EditTask(int id, [FromBody] PaymentTermDto termDto)
        {
            if (id != termDto.Id)
            {
                return(BadRequest("Idler duzgun deyil"));
            }
            foreach (var item in termDto.ContentForLang)
            {
                var termlang = await _context.PaymentTermLangs.Include(s => s.PaymentTerm).FirstOrDefaultAsync(s => s.PaymentTerm.Id == termDto.Id && s.Language.code == item.Languagename);

                termlang.Name = item.Content;
                _context.Entry(termlang).State = EntityState.Modified;
                await _context.SaveChangesAsync();
            }
            return(Ok());
        }
Esempio n. 4
0
        public static InvoiceViewModel FromDtoToView(InvoiceHeaderDto invoiceDto)
        {
            var paymentTerm = new PaymentTermDto(invoiceDto.PaymentTerm.Description.Value,
                                                 invoiceDto.PaymentTerm.DayValue)
                              with
            {
                Id = invoiceDto.PaymentTerm.Id
                ,
                Status = invoiceDto.PaymentTerm.Status
                ,
                Created = invoiceDto.PaymentTerm.Created
                ,
                Modified = invoiceDto.PaymentTerm.Modified
            };

            return(new InvoiceViewModel()
            {
                Id = invoiceDto.Id,
                Client = FromEntity(invoiceDto.Client),
                Code = invoiceDto.Code,
                Rnc = invoiceDto.Rnc,
                Ncf = invoiceDto.Ncf,
                Created = invoiceDto.InvoiceDate,
                DueDate = invoiceDto.DueDate,
                Footer = invoiceDto.Footer,
                Notes = invoiceDto.Notes,
                PaymentTerm = paymentTerm,
                TermAndConditions = invoiceDto.TermAndConditions,
                Discount = invoiceDto.Discount,
                SubTotal = invoiceDto.Subtotal,
                TaxTotal = invoiceDto.TaxTotal,
                Total = invoiceDto.Total,
                InvoiceDetails = invoiceDto.InvoiceDetails.Map(i => new InvoiceDetailViewModel()
                {
                    Id = i.Id,
                    ProductCode = i.ProductCode,
                    ProductDescription = i.ProductDescription,
                    Amount = i.Amount,
                    Qty = i.Qty,
                    TaxPercent = i.TaxPercent
                }).ToList()
            });
        }
    }
Esempio n. 5
0
 public static PaymentTerm FromDto(PaymentTermDto dto)
 => new(new Name(dto.Description)