public async Task <IActionResult> AddProductGroup(AddProductGroupDto newproductgroup) { try { return(Ok(await _productGroupService.AddProductGroup(newproductgroup))); } catch (Exception) { _logger.LogError("Failed to execute POST"); return(BadRequest()); } }
public async Task <IActionResult> AddProductGroup([FromBody] ProductGroup productGroup) { try { var addedGroup = await _productGroupService.AddProductGroup(productGroup); return(Ok(addedGroup)); } catch (DuplicateResourceException exception) { return(BadRequest(exception)); } catch (Exception exception) { return(StatusCode(StatusCodes.Status500InternalServerError, exception.Message)); } }
public ActionResult Create(CreateProductGroupPostRequest group) { if (ModelState.IsValid) { bool isSuccess = service.AddProductGroup(group.ConvertToProductGroupModel()); if (isSuccess) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("ServerError", "Add new brand fail!"); } } return(View(group)); }
public async Task <IActionResult> AddGroup([FromBody] ProductGroup productGroup) { if (productGroup is null) { throw new ArgumentNullException(nameof(productGroup)); } if (string.IsNullOrWhiteSpace(productGroup.Name)) { throw new ArgumentNullException(nameof(productGroup.Name)); } try { _logger.Debug("Adding new group with name {name}", productGroup.Name); var addedGroup = await _productGroupService.AddProductGroup(productGroup); return(Ok(addedGroup)); } catch (Exception exception) { _logger.Debug(exception.ToString()); throw; } }
public async Task <IActionResult> AddProductGroup(AddProductGroup newProductGrp) { return(Ok(await _productGroupService.AddProductGroup(newProductGrp))); }
public async Task <IActionResult> AddProductGroup(ProductGroupDTO_ToAdd input) { return(Ok(await service.AddProductGroup(input))); }