public async Task <IActionResult> PostCatalog([FromBody] AddCatalogItemData catalogItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            int catalogId = await service.CreateAsync(catalogItem);

            return(CreatedAtAction(nameof(GetCatalog), new { id = catalogId }, catalogItem));
        }
예제 #2
0
 public async Task <IActionResult> Create(Catalog catalog)
 {
     if (ModelState.IsValid)
     {
         if (await _catalogService.CreateAsync(catalog) > 0)
         {
             return(RedirectToAction(nameof(Index)));
         }
     }
     return(View(catalog));
 }
 public async Task <IActionResult> Create([Bind("Id,CatalogName,CatalogDescription,CreatedBy,CreatedDateUtc,LastModifiedBy,LastModifiedDateUtc,IsDeleted")] Catalog catalog)
 {
     if (ModelState.IsValid)
     {
         if (await _catalogService.CreateAsync(catalog) > 0)
         {
             return(RedirectToAction(nameof(Index)));
         }
     }
     return(View(catalog));
 }
예제 #4
0
        public async Task <ActionResult <CatalogDetailsDto> > CreateAsync([FromBody] CatalogNewDto newItem, string authentication)
        {
            bool check = await _authentication.IsLoginAsync(authentication);

            if (check)
            {
                var result = await _service.CreateAsync(newItem);

                if (result == null)
                {
                    return(NotFound());
                }

                return(CreatedAtAction(nameof(GetByIdAsync), new { id = result.Id }, result));;
            }
            return(BadRequest("Not Loggin"));
        }