Exemplo n.º 1
0
        public ActionResult Edit(IncomeViewModels viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    int active = 0;
                    if (viewModel.Active)
                    {
                        active = 1;
                    }
                    Income toDB = new Income();
                    toDB.Active            = active;
                    toDB.IncomeDescription = viewModel.IncomeDescription;
                    toDB.IncomeName        = viewModel.IncomeName;
                    //toDB.IncomeValue = viewModel.IncomeValue;
                    toDB.IncomeId = viewModel.IncomeId;
                    toDB.Order    = viewModel.Order;
                    incomeBL.UpdateIncome(toDB);

                    return(RedirectToAction("Index", "Income"));
                }
                else
                {
                    ModelState.AddModelError("", "Error.");
                    return(View(viewModel));
                }
            }
            catch
            {
                ModelState.AddModelError("", "Error.");
                return(View(viewModel));
            }
        }
 protected void btnUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         income.Id     = int.Parse(Request["Id"].ToString());
         income.Income = txtName.Text.Trim();
         income.UpdateIncome();
         lblMsg.Text = "Updated...!";
     }
     catch (Exception)
     {
         throw;
     }
 }
        public IActionResult Update(long id, [FromBody] Income income)
        {
            bool result = false;

            try
            {
                if (income == null || income.ID != id)
                {
                    return(BadRequest());
                }
                result = incomeBL.UpdateIncome(id, income);
                if (result == false)
                {
                    return(NotFound());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception in getting Update new Income", e);
            }
            return(new NoContentResult());
        }