public async Task <IActionResult> AddEntry([FromBody] AddEntryDto addPasswordModel) { var userId = GetUserId(); var status = await _entryService.AddEntry(addPasswordModel, userId); return(Ok(status)); }
public async Task <IActionResult> Entry(WalletEntry form) { int userId = int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)); try { await _entryService.AddEntry(form.Entry, form.Date, userId); } catch (InvalidEntryException) { ModelState.AddModelError("Entry", _localizer["ProvideKeywordAndAmount"]); return(View("Index", form)); } catch (InvalidEntryAmountException) { ModelState.AddModelError("Entry", _localizer["ProvideValidAmount"]); return(View("Index", form)); } return(View("Index", new WalletEntry { PreviousEntrySaved = true })); }
public IActionResult AddEntry(EntryViewModel model, int postId) { var UserId = 0; var user = HttpContext.User; var dbUser = _userManager.GetUserAsync(user).Result; UserId = dbUser.Id; if (ModelState.IsValid) { model.PostId = postId; model.UserId = UserId; var entryEntity = _entryService.AddEntry(model); if (entryEntity.Id > 0) { return(RedirectToAction(nameof(HomeController.Index), "Home")); } else { ModelState.AddModelError(string.Empty, "Kayıt başarısız"); } } return(View()); }
public ActionResult <Entry> Post([FromBody] Entry entry) { return(_entryService.AddEntry(entry)); }