public static OtherExpenseUpdateViewModel GetOtherExpenseById(int id)
        {
            Entities entities                 = new Entities();
            Expenses otherExpense             = entities.Expenses.Where(x => x.Id == id).FirstOrDefault();
            OtherExpenseUpdateViewModel model = new OtherExpenseUpdateViewModel
            {
                Id         = otherExpense.Id,
                Expense    = otherExpense.Value,
                ExpenseDay = otherExpense.ExpenseDay,
                Note       = otherExpense.Note,
                Source     = otherExpense.Name
            };

            return(model);
        }
        public static int UpdateOtherExpense(OtherExpenseUpdateViewModel model)
        {
            Entities entities = new Entities();
            DateTime current  = DateTime.Now;

            Expenses otherExpense = entities.Expenses.Where(x => x.Id == model.Id).FirstOrDefault();

            otherExpense.Name       = model.Source;
            otherExpense.ExpenseDay = model.ExpenseDay.Value;
            otherExpense.Value      = model.Expense.Value;
            otherExpense.Note       = model.Note;

            entities.Expenses.Attach(otherExpense);
            entities.Entry(otherExpense).State = System.Data.Entity.EntityState.Modified;
            return(entities.SaveChanges());
        }
 public ActionResult _OtherExpenseUpdateForm(OtherExpenseUpdateViewModel model)
 {
     if (ModelState.IsValid)
     {
         int result = OtherExpenseQueries.UpdateOtherExpense(model);
         if (result > 0)
         {
             return(Content("success"));
         }
         else
         {
             return(Content("failed"));
         }
     }
     else
     {
         return(PartialView());
     }
 }
        public ActionResult _OtherExpenseUpdateForm(int id)
        {
            OtherExpenseUpdateViewModel model = OtherExpenseQueries.GetOtherExpenseById(id);

            return(PartialView(model));
        }