public async Task <IActionResult> Create([FromBody] CreateBudgetReq req) { var budget = req.toEntity(HttpContext.UserId().Value); await budgetRepo.Create(budget); return(Created($"/api/budgets/${budget.Id}", budget)); }
public ActionResult Create([Bind(Include = "BUD_IDE_BUDGET,BUD_IDE_USER,BUD_IDE_ACCOUNT,BUD_IDE_AREA,BUD_DES_QUANTITY,BUD_DES_PERIOD,BUD_FH_CREATED")] Budget budget) { if (ModelState.IsValid) { budget.BUD_FH_CREATED = DateTime.Now; if (_db.Create(budget)) { return(RedirectToAction("Index")); } } return(View(budget)); }
public ActionResult Create([Bind(Include = "BUD_IDE_BUDGET,BUD_IDE_USER,BUD_IDE_ACCOUNT,BUD_IDE_AREA,BUD_DES_QUANTITY,BUD_DES_PERIOD,BUD_FH_CREATED")] Budget budget) { if (ModelState.IsValid) { var user = (CustomSerializeModel)Session["user"]; if (user != null) { budget.BUD_FH_CREATED = DateTime.Now; budget.BUD_IDE_USER = user.UserId; if (_db.Create(budget)) { return(RedirectToAction("Index")); } } else { return(RedirectToAction("Logout", "Account")); } } return(View(budget)); }