Example #1
0
        public IActionResult OnPost(int?id)
        {
            //input model to supplier
            //Update in repo
            if (id.HasValue)
            {
                var supplier = _supplierRepo.GetById(id.Value);
                supplier.CompanyName = Input.CompanyName;
                supplier.Balance     = Input.Balance;
                _supplierRepo.Update(supplier);
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(Page());
                }

                var supplier = new NoTricks.Data.Models.Supplier {
                    CompanyName = Input.CompanyName,
                    Balance     = Input.Balance
                };

                _supplierRepo.Insert(supplier);
            }

            return(RedirectToPage("Index"));
        }