public ActionResult Create([Bind(Include = "Id,Nome,Situacao")] TipoDespesa tipoDespesa) { if (ModelState.IsValid) { db.TipoDespesas.Add(tipoDespesa); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tipoDespesa)); }
public ActionResult Create([Bind(Include = "Id,Nome")] ListaReceita listaReceita) { if (ModelState.IsValid) { db.ListaReceitas.Add(listaReceita); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(listaReceita)); }
public ActionResult Create([Bind(Include = "Id,Nome,DataAniversario,Email,ConfirmarEmail,Senha,ConfirmarSenha")] Cliente cliente) { if (ModelState.IsValid) { db.Clientes.Add(cliente); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cliente)); }
public ActionResult Create([Bind(Include = "ID,TipoReceita,FormaRecebimento,DataRecebimento,Valor,Parcelamento,NumeroParcelas,PrimeiraDataVencimento,Descricao,Observacao")] Receita receita) { if (ModelState.IsValid) { db.Receitas.Add(receita); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(receita)); }
public ActionResult Create([Bind(Include = "Id,Descricao,Caracteristica,Situacao,Valor,TipoDespesaId,DataVencimentoParcela,DataRealizacao,NumParcelas")] Despesa despesa) { if (ModelState.IsValid) { db.Despesas.Add(despesa); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TipoDespesaId = new SelectList(db.TipoDespesas, "Id", "Nome", despesa.TipoDespesaId); return(View(despesa)); }
public Answer AddAndSaveToDatasebase(int x, int y) { var total = this.Add(x, y); var answer = new Answer() { Result = total.ToString() }; var db = new CalcContext(); db.Answers.Add(answer); db.SaveChanges(); return(answer); }
public void AddCalc([FromBody] Calculating calcdate) { if (!String.IsNullOrEmpty(calcdate.Term)) { string s = calcdate.Term; int iCntOprnd = 0, iCntOprt = 0; bool bflag = true; for (int i = 0; i < s.Length; i++) { if ((s[i] == '+') || (s[i] == '-') || (s[i] == '*') || (s[i] == '/')) { if (iCntOprt >= 1) { calcdate.Operations += ";"; } calcdate.Operations += s[i]; iCntOprt += 1; calcdate.Operands += ";"; if (bflag) { iCntOprnd += 1; } bflag = false; } else { calcdate.Operands += s[i]; bflag = true; if (i == s.Length - 1) { calcdate.Operands += ";"; iCntOprnd += 1; } } } if (iCntOprnd - iCntOprt == 1) { PostfixNotationExpression pn = new PostfixNotationExpression(); calcdate.Res = pn.result(s); calcdate.TimeofCalc = DateTime.Now; calcdate.UserIp = System.Web.HttpContext.Current.Request.UserHostAddress; db.Calcs.Add(calcdate); db.SaveChanges(); } } }
public void TestCalcContext() { using (CalcContext context = new CalcContext()) { for (int i = 0; i < 100; i++) { Calculation c = new Calculation() { X = i, Y = i + 1, Z = 2 * i + 1, Operation = "plus", CreateDate = DateTime.Now.AddDays(-i) }; context.Calculations.Add(c); context.SaveChanges(); } } }
public void Save() { _db.SaveChanges(); }