public async Task <ItemGetDto> AddUserAsync(ItemAddDto itemAddDto) { var item = _mapper.Map <Item>(itemAddDto); var createdItem = await _itemRepository.AddItemAsync(item); throw new NotImplementedException(); }
public async Task <IActionResult> NewItemAsync([FromBody] ItemForCreationDto item) { var finalItem = new Item { Owner = await userManager.FindByEmailAsync(item.OwnerEmail), Description = item.Description, CurrentHolderEmail = item.OwnerEmail, PhotoUrl = item.PhotoUrl, Title = item.Title, OwnerEmail = item.OwnerEmail }; var user = await userManager.FindByEmailAsync(finalItem.Owner.Email); user.Credit += 1; await itemRepository.AddItemAsync(finalItem); if (!await itemRepository.SaveAsync()) { return(BadRequest("Try agian another time.")); } return(Created($"api/items/{finalItem.Id}", finalItem)); }
public async Task CreateItems(ObjectId id, string title, string link, string description, DateTime pubDate) { var item = await _itemRepository.GetItemAsync(id); if (item == null) { throw new Exception($"Items already exists."); } item = new Item(id, title, link, description, pubDate); await _itemRepository.AddItemAsync(item); }
public async Task <ActionResult> CreateAsync([Bind("Id,Name,Description,Completed")] Item item) { if (!ModelState.IsValid) { return(View(item)); } item.Id = Guid.NewGuid().ToString(); await _itemRepository.AddItemAsync(item); return(RedirectToAction("Index")); }
public async Task <ActionResult> PostItem(ItemForCreationDto itemForCreationDto) { int budgetGroupId = itemForCreationDto.BudgetGroupId; if (!_repo.BudgetGroupByBudgetGroupIdExists(budgetGroupId)) { _logger.LogError($"Unable to find BudgetGroup with the BudgetGroupId '{budgetGroupId}'."); return(NotFound()); } Item item = _mapper.Map <Item>(itemForCreationDto); await _repo.AddItemAsync(item); ItemDto itemDto = _mapper.Map <ItemDto>(item); _logger.LogInformation($"Created Item with the ItemId '{itemDto.ItemId}'."); return(CreatedAtRoute(nameof(GetItem), new { itemId = itemDto.ItemId }, itemDto)); }
public async Task <ActionResult> AddItem(ItemAddDto itemAddDto) { try { var item = _mapper.Map <Item>(itemAddDto); if (item == null) { return(BadRequest()); } var createdUser = await _itemRepository.AddItemAsync(item); return(CreatedAtAction(nameof(GetItem), new { Id = createdUser.Id }, createdUser)); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, "Erorr adding data to the database")); } }
public async Task <ResultModel> AddItem(Item Item) { try { Tuple <bool, Exception> resultData = await itemRepository.AddItemAsync(Item); if (resultData.Item1) { return(LibFuncs.getSavedResponse(null, resultData.Item1, 0)); } else { return(LibFuncs.getExceptionResponse(resultData.Item2, "AddItem")); } } catch (Exception ex) { var st = new StackTrace(); return(LibFuncs.getExceptionResponse(ex, st.GetFrame(0).GetMethod().DeclaringType.FullName)); } }
public async Task AddItem(T t) { await _itemRepository.AddItemAsync(t); }
async Task <int> IItemUsecase.AddItemAsync(ItemModel item) { return(await _itemRepo.AddItemAsync(item)); throw new NotImplementedException(); }