Esempio n. 1
0
        public IActionResult AddBill(AddEditBillViewModel model)
        {
            if (model != null && model.Bill != null && ModelState.IsValid)
            {
                if (float.TryParse(model.Bill.Amount.Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var amount))
                {
                    var entity = new BillEntity
                    {
                        CreatedBy   = HttpContext.User.Identity.Name,
                        CreatedDate = DateTime.Now,
                        Description = model.Bill.Description,
                        PersonId    = model.Bill.PersonId,
                        Amount      = amount,
                        BillDate    = model.Bill.BillDate.Value,
                        BillId      = model.Bill.Id
                    };
                    if (entity.BillId > 0)
                    {
                        _billsService.UpdateBill(entity);
                    }
                    else
                    {
                        _billsService.AddBill(entity);
                    }
                }
            }

            return(RedirectToAction(nameof(BillsList)));
        }
Esempio n. 2
0
        public IActionResult AddBill(AddBillViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            var entity = new BillEntity
            {
                CreatedBy   = HttpContext.User.Identity.Name,
                CreatedDate = DateTime.Now,
                Description = model.Description,
                PersonId    = model.PersonId,
                Amount      = model.Amount,
                BillDate    = model.BillDate
            };

            _billsService.AddBill(entity);
            return(View(new AddBillViewModel()));
        }
Esempio n. 3
0
 public IActionResult AddBill([FromBody] BillDTO billDTO)
 {
     _logger.LogInformation("Executing AddBill controller");
     return(Ok(_billService.AddBill(billDTO)));
 }