public async Task <Result <int> > Handle(CreateIndustryCommand request, CancellationToken cancellationToken) { var id = _authenticatedUser.UserId; var category = _mapper.Map <Industry>(request); await _repository.InsertAsync(category); await _unitOfWork.Commit(cancellationToken); return(Result <int> .Success(category.Id)); }
public async Task <ActionResultReponese <string> > InsertAsync(string idDepartment, IndustryMeta industryMeta) { var isdepartment = await _iDepartmentRepository.CheckExitsByIdDepartment(idDepartment); if (!isdepartment) { return(new ActionResultReponese <string>(-21, "IdDepartment khong ton tai", "Department")); } var isnameIndustry = await _iindustryRepository.checkexitNameIndustry(industryMeta.NameIndustry); if (isnameIndustry) { return(new ActionResultReponese <string>(-31, "NameIndustry da ton tai", "Industry")); } var _industry = new Industry { IdIndustry = Guid.NewGuid().ToString(), NameIndustry = industryMeta.NameIndustry?.Trim(), IdDepartment = idDepartment?.Trim(), Address = industryMeta.Address?.Trim(), Email = industryMeta.Email?.Trim(), PhoneNumber = industryMeta.PhoneNumber?.Trim(), Details = industryMeta.Details?.Trim(), CreateDate = DateTime.Now, Deletetime = null, LastUpdate = null, IsActive = true, IsDelete = false, }; var code = await _iindustryRepository.InsertAsync(_industry); if (code >= 0) { return(new ActionResultReponese <string>(code, "Insert thanh cong", "Industry")); } return(new ActionResultReponese <string>(code, "Insert that bai", "Industry")); }