public async Task <IActionResult> DeleteConfirmed(Guid id) { if (id == default(Guid)) { return(NotFound()); } else if ([email protected]) { return(Unauthorized()); } ProductGroup productGroup; try { productGroup = await _productGroupRepository.Get(p => p.Id == id); if (productGroup == null) { return(NotFound()); } if ((await _productGroupRepository.GetMany(p => p.ParentId == productGroup.Id)).Any()) { ViewBag.UserMessage = "The product has chidren. Cannot be deleted at this time"; return(View(productGroup)); } } catch (Exception ex) { _logger.LogCritical(500, ex.Message, ex); return(StatusCode(500, ex.Message)); } if (!await _authRepository.IsAuthedRole(@User.Identity.Name.Substring(@User.Identity.Name.IndexOf(@"\") + 1))) { ViewBag.UserMessage = "You are not authorised to delete this product Group. Please contact your local customer relationship manager."; return(View(productGroup)); } try { await _productGroupRepository.Delete(productGroup); await _legacyFileRepository.Publish(); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { _logger.LogCritical(500, ex.Message, ex); return(StatusCode(500, ex.Message)); } }
public async Task <IActionResult> DeleteProductGroup(string name) { if (!await _productGroupRepository.ProductGroupExists(name)) { return(NotFound()); } var productGroup = await _productGroupRepository.GetProductGroupByName(name); _productGroupRepository.Delete(productGroup); await _unitOfWork.Commit(); return(NoContent()); }
public async Task DeleteProductGroup(Guid id) { await _productGroupRepository.Delete(id); }
public void Delete(ProductGroup productGroup) { DeleteValidate(productGroup.Id); _productGroupRepository.Delete(productGroup); _unitOfWork.Commit(); }
public bool Delete(ProductGroupModel model) { return(_res.Delete(model)); }
/// <summary> /// /// </summary> /// <param name="objProductGroup"></param> public void DeleteProductGroup(ProductGroup objProductGroup) { _roleRepository.Delete(objProductGroup); _unitOfWork.Commit(); }