public async Task <IActionResult> CreateCards([FromForm] string name) { if (ModelState.IsValid) { string id = GetCurrentUserId(); // if user id not found => redirect to login view if (id == String.Empty) { return(RedirectToAction(nameof(AccountController.Login), "Account")); } CardsCollection cardsCollection = new CardsCollection { AppUserId = id, DateOfCreation = DateTimeOffset.Now, Name = name }; var result = await _crudCardsService.AddAsync(cardsCollection); if (result != null) { return(RedirectToAction("AllCards")); } else { return(RedirectToAction(nameof(HomeController.Error), "Home")); } } return(RedirectToAction("AllCards")); }
public async Task <IActionResult> AddCard(CardVM model, int idCards) { string id = GetCurrentUserId(); // if user id not found => redirect to login view if (id == String.Empty) { return(RedirectToAction(nameof(AccountController.Login), "Account")); } if (ModelState.IsValid) { Card card = new Card { Interval = DateTimeOffset.Now.ToUnixTimeMilliseconds(), GroupRepetition = 0, Efactor = 3.0, DtoInterval = DateTimeOffset.Now, UserScore = 0, CardsId = idCards, Item = new Item { Face = model.Item.Face, Back = model.Item.Back } }; var result = await _crudCardService.AddAsync(card); if (result != null) { return(RedirectToAction("AllCards")); } else { return(RedirectToAction(nameof(HomeController.Error), "Home")); } } return(View(model)); }
public async Task <IActionResult> AddAsync([FromBody] CompanyDTO company) { var apiResponse = await companies.AddAsync(company); return(this.GetActionResult(apiResponse, logger)); }
public async Task <IActionResult> AddAsync([FromBody] WorkerDTO worker) { var apiResponse = await workers.AddAsync(worker); return(this.GetActionResult(apiResponse, logger)); }