public ActionResult <GeneralItemDTO> AddItem(GeneralItemDTO item) { IdentityUser currentUser = GetCurrentUser(); if (currentUser == null) { return(BadRequest()); } GeneralCategory category = _itemRepository.GetCategoryBy(item.Category.Id); GeneralItem itemToCreate = new GeneralItem(item, category, currentUser); _itemRepository.Add(itemToCreate); _itemRepository.SaveChanges(); return(Ok(itemToCreate.Id)); }
public GeneralItem(GeneralItemDTO item, GeneralCategory category, IdentityUser user) { Name = item.Name; Category = category; User = user; }